| 1 |
Manage Globus Auth Projects |
| 2 |
=========================== |
| 3 |
|
| 4 |
.. note:: |
| 5 |
|
| 6 |
The following scripts, when run, may leave tokens in a JSON file in |
| 7 |
your home directory. Be sure to delete these tokens after use. |
| 8 |
|
| 9 |
List Projects via the Auth API |
| 10 |
------------------------------ |
| 11 |
|
| 12 |
The following is a very small and simple script using the Globus Auth Developer |
| 13 |
APIs. |
| 14 |
|
| 15 |
It uses the tutorial client ID from the :ref:`tutorials <tutorials>`. |
| 16 |
For simplicity, the script will prompt for login on each use. |
| 17 |
|
| 18 |
.. literalinclude:: list_projects.py |
| 19 |
:caption: ``list_projects.py`` [:download:`download <list_projects.py>`] |
| 20 |
:language: python |
| 21 |
|
| 22 |
|
| 23 |
List and Create Projects via the Auth API |
| 24 |
----------------------------------------- |
| 25 |
|
| 26 |
The next example builds upon the earlier example by offering a pair of |
| 27 |
features, List and Create. |
| 28 |
|
| 29 |
Argument parsing allows for an action to be selected, which is then executed by |
| 30 |
calling the appropriate function. |
| 31 |
|
| 32 |
.. literalinclude:: list_and_create_projects.py |
| 33 |
:caption: ``list_and_create_projects.py`` [:download:`download <list_and_create_projects.py>`] |
| 34 |
:language: python |
| 35 |
|
| 36 |
|
| 37 |
List, Create, and Delete Projects via the Auth API |
| 38 |
-------------------------------------------------- |
| 39 |
|
| 40 |
.. warning:: |
| 41 |
|
| 42 |
The following script has destructive capabilities. |
| 43 |
|
| 44 |
Deleting projects may be harmful to your production applications. |
| 45 |
Only delete with care. |
| 46 |
|
| 47 |
The following example expands upon the former by adding delete functionality. |
| 48 |
|
| 49 |
Because Delete requires authentication under a session policy, the login code |
| 50 |
grows here to include a storage adapter (with data kept in |
| 51 |
``~/.sdk-manage-projects.json``). If a policy failure is encountered, the code |
| 52 |
will prompt the user to login again to satisfy the policy and then reexecute |
| 53 |
the desired activity. |
| 54 |
|
| 55 |
As a result, this example is significantly more complex, but it still follows |
| 56 |
the same basic pattern as above. |
| 57 |
|
| 58 |
.. literalinclude:: manage_projects.py |
| 59 |
:caption: ``manage_projects.py`` [:download:`download <manage_projects.py>`] |
| 60 |
:language: python |