Commit 6cda3deb authored by Gao, Shang's avatar Gao, Shang
Browse files

testing remote auth script

parent 8b9bbfd4
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -87,6 +87,7 @@ class crossbowGlobus(crossbowBase):
        self.client_id = '18270179-b498-4032-9187-ca646d6e29af'
        #self.cadesdtn = 'e6bcd4fa-ac1b-11e6-9aee-22000a1e3b52'
        self.cadesdtn = '586dc9b6-189a-11e7-bb9f-22000b9a448b'
        self.token_file = token_file

        if init:
            try:
@@ -149,6 +150,14 @@ class crossbowGlobus(crossbowBase):
        authorize_url = client.oauth2_get_authorize_url()
        return authorize_url
        
    def _dl_refresh_tokens(self,auth_code)
        """
        manually saves refresh tokens to file
        """
        token_response = client.oauth2_exchange_code_for_tokens(auth_code)
        tokens = token_response.by_resource_server
        self._save_tokens_to_file(token_file, tokens)
        
    def _activate_endpoint(self,ep_id):
        """
        function for manually activating an endpoint
+17 −6
Original line number Diff line number Diff line
@@ -44,13 +44,24 @@ class crossbowOlcf(object):
                                   else cd crossbow/; git pull; fi" % olcf_path)
        print ssh_stdout.readlines()
        
        time.sleep(5)
        time.sleep(1)

        #export python paths
        ssh_stdin, ssh_stdout, ssh_stderr = \
            self.ssh.exec_command("export PATH=/ccs/home/iamshang/anaconda2/bin:/ccs/home/iamshang/anaconda2/lib/python2.7/site-packages:$PATH;\
                                   export PYTHONPATH=/ccs/home/iamshang/crossbow/crossbow:$PYTHONPATH;\
                                   cd crossbow/crossbow; python remote_auth.py")
        url = ssh_stdout.readlines()
        time.sleep(1)
        print 'Please go to this URL and login: %s' % url

        get_input = getattr(__builtins__, 'raw_input', input)
        auth_code = get_input('Please enter the code you get after login here: ').strip()

        #get tokens
        ssh_stdin, ssh_stdout, ssh_stderr = \
            self.ssh.exec_command("cd crossbow/crossbow; python remote_auth_1.py")
        url = ssh_stdout.readlines()[0]
        print url
            self.ssh.exec_command("export PATH=/ccs/home/iamshang/anaconda2/bin:/ccs/home/iamshang/anaconda2/lib/python2.7/site-packages:$PATH;\
                                   export PYTHONPATH=/ccs/home/iamshang/crossbow/crossbow:$PYTHONPATH;\
                                   cd crossbow/crossbow; python remote_auth.py %s" % auth_code)
        
if __name__ == "__main__":
    olcf = crossbowOlcf('rhea')
+13 −0
Original line number Diff line number Diff line
from crossbowGlobus import crossbowGlobus
import sys

if len(sys.argv) > 1:
    url = sys.argv[1]
    
    cbow = crossbowGlobus(api_key="eaabd7d9-3cb4-4014-85fe-73736e658472",init=False)
    cbow._dl_refresh_tokens(url)

else:
    cbow = crossbowGlobus(api_key="eaabd7d9-3cb4-4014-85fe-73736e658472",init=False)
    url = cbow._get_authorize_url(cbow.client_id)
    sys.stdout.write(url)

crossbow/remote_auth_1.py

deleted100644 → 0
+0 −5
Original line number Diff line number Diff line
from crossbowGlobus import crossbowGlobus

cbow = crossbowGlobus(api_key="eaabd7d9-3cb4-4014-85fe-73736e658472",init=False)
url = cbow._get_authorize_url(cbow.client_id)
print url