Authentication and API keys¶
Scripts log in to datalab with an API key. A key acts as you, with all of your permissions.
Create a key¶
- Click your name at the top of the page, then Account settings.
- Open the API keys tab.
- Give the key a label that says where it will be used, such as "laptop notebooks" or "XRD Beholder".
- Click Generate new key.
- Copy the key straight away. It is only shown once.
You can have several keys. Use a separate key for each script or computer. Then you can revoke one without breaking the others.
Where to put it¶
Set it as an environment variable before starting Python:
If you use more than one instance, put the instance's identifier prefix in capitals at the
start. For an instance with the prefix grey:
The Python client picks the right key for each instance.
Never commit an API key
Anyone with your key can do anything you can do. Keep it in an environment variable or a git-ignored secrets file. Never put it in a notebook or script you share.
Revoking a key¶
Keys do not expire. To stop a key working, open Account settings, go to API keys, and revoke it.
If a key may have leaked, revoke it at once and create a new one.