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