Skip to content

Instantly share code, notes, and snippets.

@akkornel
Created March 23, 2018 05:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akkornel/5b9a820c54ff80c1f05db257a964b0be to your computer and use it in GitHub Desktop.
Save akkornel/5b9a820c54ff80c1f05db257a964b0be to your computer and use it in GitHub Desktop.
Show the Globus endpoint_cert API used to fetch an endpoint key & cert
# vim: ts=2 sw=2 et
# To use this, first, install the `globus-sdk` package via pip.
# Next, go to https://developers.globus.org
# Choose "Register your app with Globus".
# Make a new project, with whatever name & email you want.
# Then, go to the "Add…" menu, and choose "Add a new app".
# Choose whatever app name you want.
# For _Redirect URLs_, enter `http://localhost:4000`.
# For _Scopes_, choose `urn:globus:auth:scope:transfer.api.globus.org:all`.
# Leave all other settings along.
# After creating your app, generate a new client secret.
# Put the client ID and client secret into the variables below.
# Delete the app & project when you're done running this code!
import globus_sdk
scopes = "urn:globus:auth:scope:transfer.api.globus.org:all"
client_id = "7d24fc9b-3bf9-447e-8c82-c912a8b88f0d"
client_secret = "GIvYsChpvaMO509YA+Mr2e/94u6wbPgzwB6ufenjK5E="
# Set up our authenticator and authorizer
authn = globus_sdk.ConfidentialAppAuthClient(
client_id=client_id,
client_secret=client_secret
)
authz = globus_sdk.ClientCredentialsAuthorizer(authn, scopes)
# Create our API object and request a key & cert
api = globus_sdk.base.BaseClient(
service='transfer',
authorizer=authz,
base_url='https://transfer.api.globusonline.org/',
base_path='v0.10'
)
response = api.post('/private/endpoint_cert')
# Extract and output the data
response = response.data
print("Subject is: %s\nCert:\n%s\nKey:\n%s" % (
response['subject'],
response['cert'],
response['key']
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment