Create a gist now

Instantly share code, notes, and snippets.

from globusonline.graph import data_store
import globusonline.graph
from globusonline.graph.request import TestRequest
from globusonline.graph.users import resources as users
from globusonline.graph import groups
from ConfigParser import RawConfigParser
from sys import argv
# Setup:
config = RawConfigParser()
GO_CONFIG = argv[1] if len(argv) > 1 else '/home/mattias/virtualenv/globusonline-graph/development.ini'
app_options = dict(config.items('app:graph'))
store = data_store.from_settings(app_options)
crypto =['shared_secret'])
request = TestRequest(store, crypto)
# Do stuff:
import uuid
from globusonline.graph.credentials.resources import UserCredentials
from globusonline.graph.users.resources import User
import globusonline.graph.credentials.utils as cred_utils
for rel in store.get_reference_node("myproxy").instance:
cred = rel.target_node.attributes
if not rel.target_node.has_myproxy.incoming.single:
user_node = rel.target_node.has_myproxy.incoming.single.source_node
user = User(None, user_node, request)
print cred
if cred.has_key('server') and cred.has_key('username') and cred.has_key('id_index') and \
"/O=Grid/OU=GlobusTest/ Simple CA" in (cred['x509_issuer']):
credential_id = cred['username'] + '_' + ''
cred['server'] = ''
unique_key = str(uuid.uuid4())
#user_creds = UserCredentials(user, request.data_store)
user_creds = user.credentials
if cred_utils.credential_exists_by_id(store, 'oauth', credential_id):
print("OAuth credential already exists")
print("Inserting new credential")
user_creds.add_credential('oauth', unique_key, credential_id, cred)
except Exception as e:
print("Caught: ")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment