예제 #1
0
    def get_user_info(self, access_token):

        oauth_client = oauth2.Client(self.oauth_settings['client_id'],
                                     self.oauth_settings['client_secret'],
                                     self.oauth_settings['access_token_url'])

        (headers, body) = oauth_client.request('https://api.github.com/user',
                                               access_token=access_token,
                                               token_param='access_token')
        return simplejson.loads(body)
예제 #2
0
    def get_authorize_url(self):
        oauth_client = oauth2.Client(self.oauth_settings['client_id'],
                                     self.oauth_settings['client_secret'],
                                     self.oauth_settings['authorization_url'])

        authorization_url = oauth_client.authorization_url(
            redirect_uri=self.oauth_settings['redirect_url'],
            params={'scope': self.oauth_settings['scope']})

        return authorization_url
예제 #3
0
    def get_access_token(self, code):
        oauth_client = oauth2.Client(self.oauth_settings['client_id'],
                                     self.oauth_settings['client_secret'],
                                     self.oauth_settings['access_token_url'])

        data = oauth_client.access_token(code,
                                         self.oauth_settings['redirect_url'])

        access_token = data.get('access_token')

        return access_token