| 1 |
.. _userguide_register_service_account: |
| 2 |
|
| 3 |
Registering a Service Account |
| 4 |
============================= |
| 5 |
|
| 6 |
In order to be used as a Service Account or "Client Identity", a client must |
| 7 |
be registered in Globus Auth under the correct type. |
| 8 |
|
| 9 |
This is similar to the |
| 10 |
:ref:`getting started documentation on registering an app <tutorial_register_app>`, |
| 11 |
but using some different settings. |
| 12 |
|
| 13 |
Creating the Client |
| 14 |
------------------- |
| 15 |
|
| 16 |
The following steps will walk you through how to register a client for use as a |
| 17 |
service account. |
| 18 |
One topic not covered here is how to securely store and manage your secrets -- |
| 19 |
the guidance below will simply say "save", and it is the user's responsibility |
| 20 |
to decide how to save and secure these credentials. |
| 21 |
|
| 22 |
1. Navigate to the `Developer Site <https://app.globus.org/settings/developers>`_ |
| 23 |
|
| 24 |
2. Select "Register a service account or application credential for automation" |
| 25 |
|
| 26 |
3. Create or Select a Project |
| 27 |
|
| 28 |
* A project is a collection of apps with a shared list of administrators. |
| 29 |
* If you don't own any projects, you will automatically be prompted to create one. |
| 30 |
* If you do, you will be prompted to either select an existing or create a new one. |
| 31 |
|
| 32 |
4. Creating or selecting a project will prompt you for another login, sign in with an |
| 33 |
account that administers your project. |
| 34 |
|
| 35 |
5. Give your App a name. This will appear as the identity's "name" where a |
| 36 |
user's full name might appear. |
| 37 |
|
| 38 |
6. Click "Register App". This will create your app and take you to a page |
| 39 |
describing it. |
| 40 |
|
| 41 |
7. Copy the "Client UUID" and save it -- this is your ``client_id`` in the |
| 42 |
Python SDK's terms. |
| 43 |
|
| 44 |
8. Click "Add Client Secret", fill in the label, and save the secret -- this is |
| 45 |
your ``client_secret`` in the Python SDK's terms. |
| 46 |
|
| 47 |
|
| 48 |
Saving and Retrieving Client IDs and Secrets |
| 49 |
-------------------------------------------- |
| 50 |
|
| 51 |
The Globus SDK does not offer special capabilities for storage and retrieval of |
| 52 |
client IDs and client secrets. |
| 53 |
|
| 54 |
In examples in SDK documentation, you will see the client ID and secret written |
| 55 |
as hardcoded constants, e.g. |
| 56 |
|
| 57 |
.. code-block:: python |
| 58 |
|
| 59 |
import globus_sdk |
| 60 |
|
| 61 |
CLIENT_ID = "YOUR ID HERE" |
| 62 |
CLIENT_SECRET = "YOUR SECRET HERE" |
| 63 |
|
| 64 |
client = globus_sdk.ConfidentialAppAuthClient(CLIENT_ID, CLIENT_SECRET) |
| 65 |
|
| 66 |
You can replace those variables with sources of your choice. |
| 67 |
For example, you could make them environment variables: |
| 68 |
|
| 69 |
.. code-block:: python |
| 70 |
|
| 71 |
import os |
| 72 |
|
| 73 |
CLIENT_ID = os.getenv("CLIENT_ID") |
| 74 |
CLIENT_SECRET = os.getenv("CLIENT_SECRET") |
| 75 |
|
| 76 |
if not (CLIENT_ID and CLIENT_SECRET): |
| 77 |
raise RuntimeError("CLIENT_ID and CLIENT_SECRET must both be set.") |
| 78 |
|
| 79 |
Selecting an appropriate storage and retrieval mechanism for client credentials |
| 80 |
is considered a user responsibility by the SDK. |