Commit e8b898c1 authored by Gao, Shang's avatar Gao, Shang
Browse files

testing remote auth script

parent c1aad5b5
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ import json
import sys
import os
import time
import pickle

olcfatlas = 'ef1a9560-7ca1-11e5-992c-22000b96db58'

@@ -147,15 +148,21 @@ class crossbowGlobus(crossbowBase):
        # pass refresh_tokens=True to request refresh tokens
        client.oauth2_start_flow(refresh_tokens=True)

        # pickle client for use in _dl_refresh_tokens
        authorize_url = client.oauth2_get_authorize_url()
        with open('globus_auth_client.pkl', 'wb') as f:
            pickle.dump(client, f, protocol=pickle.HIGHEST_PROTOCOL)

        return authorize_url
        
    def _dl_refresh_tokens(self,client_id,auth_code):
    def _dl_refresh_tokens(self,client_pkl,auth_code):
        """
        manually saves refresh tokens to file
        """
        client = globus_sdk.NativeAppAuthClient(client_id=client_id)
        client.oauth2_start_flow(refresh_tokens=True)
        # load client from _get_authorize_url
        with open('globus_auth_client.pkl', 'rb') as f:
            client = pickle.load(f)
    
        token_response = client.oauth2_exchange_code_for_tokens(auth_code)
        tokens = token_response.by_resource_server
        self._save_tokens_to_file(token_file, tokens)
+1 −1
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@ if len(sys.argv) > 1:
    url = sys.argv[1]
    
    cbow = crossbowGlobus(api_key="eaabd7d9-3cb4-4014-85fe-73736e658472",init=False)
    cbow._dl_refresh_tokens(cbow.client_id,url)
    cbow._dl_refresh_tokens(url)

else:
    cbow = crossbowGlobus(api_key="eaabd7d9-3cb4-4014-85fe-73736e658472",init=False)