File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212``` python
1313>> > import transip
1414# Initialize a TransIP API client
15- >> > client = transip.TransIP(access_token = " TOKEN" )
15+ >> > client = transip.TransIP(
16+ ... login = " demouser" ,
17+ ... private_key_file = " /path/to/private.key"
18+ ... )
1619# Retrieve a list of VPSs
1720>> > for vps in client.vpss.list():
1821... print (vps)
Original file line number Diff line number Diff line change @@ -29,7 +29,10 @@ Release v\ |version|. (:ref:`Installation <install>`)
2929
3030 >>> import transip
3131 # Initialize a TransIP API client
32- >>> client = transip.TransIP(access_token="TOKEN")
32+ >>> client = transip.TransIP(
33+ ... login="demouser",
34+ ... private_key_file="/path/to/private.key"
35+ ... )
3336 # Retrieve a list of VPSs
3437 >>> for vps in client.vpss.list():
3538 ... print(vps)
Original file line number Diff line number Diff line change @@ -9,6 +9,10 @@ First, make sure that:
99
1010* python-transip is :ref: `installed <install >`
1111
12+ Then you should be able to import the module::
13+
14+ >>> import transip
15+
1216Below you'll find some simple example to get started.
1317
1418Authentication
@@ -17,7 +21,20 @@ Authentication
1721In order to make requests to the TransIP API we need to authenticate yourself
1822using an access token. To get an access token, you should first login to the
1923TransIP control panel. You can then generate a new token which will only be
20- valid for limited time.
24+ valid for limited time or generate a private key to allow python-transip to
25+ request a access token on initialization.
26+
27+ Example of authentication using a private key::
28+
29+ >>> PRIVATE_KEY = """-----BEGIN RSA PRIVATE KEY-----
30+ ... ...
31+ ... -----END RSA PRIVATE KEY-----"""
32+ >>> client = transip.TransIP(login="demouser", private_key=PRIVATE_KEY)
33+ >>> client = transip.TransIP(login="demouser", private_key_file='/path/to/private.key')
34+
35+ Example authentication using an access token::
36+
37+ >>> client = transip.TransIP(access_token="eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6ImN3MiFSbDU2eDNoUnkjelM4YmdOIn0.eyJpc3MiOiJhcGkudHJhbnNpcC5ubCIsImF1ZCI6ImFwaS50cmFuc2lwLm5sIiwianRpIjoiY3cyIVJsNTZ4M2hSeSN6UzhiZ04iLCJpYXQiOjE1ODIyMDE1NTAsIm5iZiI6MTU4MjIwMTU1MCwiZXhwIjoyMTE4NzQ1NTUwLCJjaWQiOiI2MDQ0OSIsInJvIjpmYWxzZSwiZ2siOmZhbHNlLCJrdiI6dHJ1ZX0.fYBWV4O5WPXxGuWG-vcrFWqmRHBm9yp0PHiYh_oAWxWxCaZX2Rf6WJfc13AxEeZ67-lY0TA2kSaOCp0PggBb_MGj73t4cH8gdwDJzANVxkiPL1Saqiw2NgZ3IHASJnisUWNnZp8HnrhLLe5ficvb1D9WOUOItmFC2ZgfGObNhlL2y-AMNLT4X7oNgrNTGm-mespo0jD_qH9dK5_evSzS3K8o03gu6p19jxfsnIh8TIVRvNdluYC2wo4qDl5EW5BEZ8OSuJ121ncOT1oRpzXB0cVZ9e5_UVAEr9X3f26_Eomg52-PjrgcRJ_jPIUYbrlo06KjjX2h0fzMr21ZE023Gw")
2138
2239TransIP also provide a **demo token ** to authenticate yourself as the TransIP
2340demo user in test mode::
You can’t perform that action at this time.
0 commit comments