Пример #1
0
        'auth_uri': "https://accounts.google.com/o/oauth2/auth",
        'token_uri': "https://accounts.google.com/o/oauth2/token",
        'scope': [r'http://gdata.youtube.com'],
        'redirect_uri': "urn:ietf:wg:oauth:2.0:oob"
        }

    extra_auth_params = {
        'response_type': "code",
        'access_type': "offline"
        }

    extra_token_params = {
        'grant_type': "authorization_code",
        }

    storage = FileStorage('youtube.dat')
    credentials = storage.get()
    if credentials is None:
        flow = OAuth2AuthorizationFlow(required_params,
                                       extra_auth_params,
                                       extra_token_params,
                                       True)
        flow.retrieve_authorization_code()
        credentials = flow.retrieve_token()
        storage.save(credentials)
    
    access_token = credentials['access_token']
    
    req = YouTubeAPIRequest(access_token)
    data = req.request(yt_feed_uri)
    print data
Пример #2
0
        'client_id': nc.fhirclient_id,
        'client_secret': nc.fhirclient_secret,
        'auth_uri':
        "http://" + nc.fhirurl + ":" + nc.fhirauthport + "/oauth2/auth",
        'token_uri':
        "http://" + nc.fhirurl + ":" + nc.fhirauthport + "/oauth2/token",
        'scope': ["http://" + nc.fhirurl + ":" + nc.fhiraccessport],
        'redirect_uri': "urn:ietf:wg:oauth:2.0:oob"
    }

    extra_auth_params = {'response_type': "code", 'access_type': "offline"}

    extra_token_params = {
        'grant_type': "authorization_code",
    }

    storage = FileStorage('fhiroauth2.dat')
    credentials = storage.get()
    if credentials is None:
        flow = OAuth2AuthorizationFlow(required_params, extra_auth_params,
                                       extra_token_params, True)
        flow.retrieve_authorization_code()
        credentials = flow.retrieve_token()
        storage.save(credentials)

    access_token = credentials['access_token']

    req = FHIRRequest(access_token)
    data = req.request(fhirrequest)
    print data
Пример #3
0
    required_params = {
        'client_id': "XXXXXXXXXXXXX.apps.googleusercontent.com",
        'client_secret': "XXXXXXXXXXXXXXXXXXX",
        'auth_uri': "https://accounts.google.com/o/oauth2/auth",
        'token_uri': "https://accounts.google.com/o/oauth2/token",
        'scope': [r'http://gdata.youtube.com'],
        'redirect_uri': "urn:ietf:wg:oauth:2.0:oob"
    }

    extra_auth_params = {'response_type': "code", 'access_type': "offline"}

    extra_token_params = {
        'grant_type': "authorization_code",
    }

    storage = FileStorage('youtube.dat')
    credentials = storage.get()
    if credentials is None:
        flow = OAuth2AuthorizationFlow(required_params, extra_auth_params,
                                       extra_token_params, True)
        flow.retrieve_authorization_code()
        credentials = flow.retrieve_token()
        storage.save(credentials)

    access_token = credentials['access_token']

    req = YouTubeAPIRequest(access_token)
    data = req.request(yt_feed_uri)
    print data
Пример #4
0
 def test_normal(self):
     test_storage = FileStorage(test_file)
     assert test_storage.get() == test_credential
Пример #5
0
 def test_none(self):
     test_storage = FileStorage("dummy.dat")
     assert test_storage.get() is None
Пример #6
0
 def test_normal(self):
     m = mock.Mock()
     test_storage = FileStorage(m.filename)
     assert test_storage.filename == m.filename