Get OAuth access token so we can make requests
544057
def request_access(self, verifier):
        
        client = OAuth1(
            client_key=self._server_cache[self.client.server].key,
            client_secret=self._server_cache[self.client.server].secret,
            resource_owner_key=self.store["oauth-request-token"],
            resource_owner_secret=self.store["oauth-request-secret"],
            verifier=verifier,
        )

        request = {"auth": client}
        response = self._requester(
            requests.post,
            "oauth/access_token",
            **request
        )

        data = parse.parse_qs(response.text)

        self.store["oauth-access-token"] = data[self.PARAM_TOKEN][0]
        self.store["oauth-access-secret"] = data[self.PARAM_TOKEN_SECRET][0]
        self._server_tokens = {}
1179874
def get_access_token(self, request, callback=None):
        """"""
        callback = request.build_absolute_uri(callback or request.path)
        if not self.check_application_state(request):
            logger.error('Application state check failed.')
            return None
        if 'code' in request.GET:
            args = {
                'client_id': self.consumer_key,
                'redirect_uri': callback,
                'client_secret': self.consumer_secret,
                'code': request.GET['code'],
                'grant_type': 'authorization_code',
            }
        else:
            logger.error('No code returned by the provider')
            return None
        try:
            response = self.request('post', self.access_token_url, data=args)
            response.raise_for_status()
        except RequestException as e:
            logger.error('Unable to fetch access token: {0}'.format(e))
            return None
        else:
            return response.text
32505
def construct_oauth_url(self):
        
        response = self._requester(requests.head, 
                                   "{0}://{1}/".format(self.protocol, self.client.server),
                                   allow_redirects=False
                                  )
        if response.is_redirect:
            server = response.headers['location']
        else:
            server = response.url

        path = "oauth/authorize?oauth_token={token}".format(
            token=self.store["oauth-request-token"]
        )
        return "{server}{path}".format(
            server=server,
            path=path
        )
1263389
def request_access_token(self, code, redirect_uri=None):
        '''
        
        '''
        redirect = redirect_uri or self._redirect_uri
        resp_text = _http('POST', 'https://api.weibo.com/oauth2/access_token',
                          client_id=self._client_id, client_secret=self._client_secret,
                          redirect_uri=redirect, code=code, grant_type='authorization_code')
        r = _parse_json(resp_text)
        current = int(time.time())
        expires = r.expires_in + current
        remind_in = r.get('remind_in', None)
        if remind_in:
            rtime = int(remind_in) + current
            if rtime < expires:
                expires = rtime
        return JsonDict(access_token=r.access_token, expires=expires, uid=r.get('uid', None))
48553
def request(uri, data=nil, verb=:post)
      @logger.info(uri) if @logger
      auth_check
      query = {
        path: File.join('v1.0/me/', URI.escape(uri)),
        headers: {
          'Authorization': "Bearer #{@access_token.token}"
        }
      }
      if data
        query[:body] = JSON.generate(data)
        query[:headers]['Content-Type'] = 'application/json'
        @logger.info(query[:body]) if @logger
        verb = :post unless [:post, :put, :patch, :delete].include?(verb)
        response = @conn.send(verb, query)
      else
        response = @conn.get(query)
      end
      JSON.parse(response.body)
    end
171735
def _request_access_token(self):
        
        payload = {'grant_type': 'authorization_code',
                   'code': code,
                   'redirect_uri': self.redirect_uri}

        headers = _make_authorization_headers(self.client_id,
                                              self.client_secret)

        response = requests.post(self.OAUTH_TOKEN_URL, data=payload,
                                 headers=headers,
                                 verify=LOGIN_VERIFY_SSL_CERT)

        if response.status_code is not 200:
            raise MercedesMeAuthError(response.reason)
        token_info = response.json()
        return token_info
549537
def _get_request_token(self):
        
        if self.request_token is None:
            get_params = {}
            if self.parameters:
                get_params.update(self.parameters)
            get_params['oauth_callback'] \
                = self.request.build_absolute_uri(self.callback_url)
            rt_url = self.request_token_url + '?' + urlencode(get_params)
            oauth = OAuth1(self.consumer_key,
                           client_secret=self.consumer_secret)
            response = requests.post(url=rt_url, auth=oauth)
            if response.status_code not in [200, 201]:
                raise OAuthError(
                    _('Invalid response while obtaining request token'
                      ' from "%s".') % get_token_prefix(
                          self.request_token_url))
            self.request_token = dict(parse_qsl(response.text))
            self.request.session['oauth_%s_request_token' % get_token_prefix(
                self.request_token_url)] = self.request_token
        return self.request_token
1068322
def request_token(self):
        
        client = OAuth1(
            client_key=self._server_cache[self.client.server].key,
            client_secret=self._server_cache[self.client.server].secret,
            callback_uri=self.callback,
        )

        request = {"auth": client}
        response = self._requester(
            requests.post,
            "oauth/request_token",
            **request
        )

        data = parse.parse_qs(response.text)
        data = {
            'token': data[self.PARAM_TOKEN][0],
            'token_secret': data[self.PARAM_TOKEN_SECRET][0]
        }

        return data
271402
def get_request_token(
        cls, consumer_key, redirect_uri='http://example.com/', state=None
    ):
        '''
        

        '''
        headers = {
            'X-Accept': 'application/json',
        }
        url = 'https://getpocket.com/v3/oauth/request'
        payload = {
            'consumer_key': consumer_key,
            'redirect_uri': redirect_uri,
        }

        if state:
            payload['state'] = state

        return cls._make_request(url, payload, headers)[0]['code']
125280
def get_access_token
      @client = TwitterOAuth::Client.new(:consumer_key => ConsumerKey, :consumer_secret => ConsumerSecret)
      request_token = @client.request_token
      # ask the user to visit the auth url
      puts "To authenticate your client, visit the URL: #{request_token.authorize_url}"
      open_link request_token.authorize_url
      # wait for the user to give us the PIN back
      print 'Enter PIN: '
      begin
        @client.authorize(request_token.token, request_token.secret, :oauth_verifier => self.class.get_input.chomp)
      rescue OAuth::Unauthorized
        false # Didn't get an access token
      end
    end
895039
function GetAccessToken(callback)
	{
		// do we have a refresh token? Or do we need to login from scratch?
		if (auth_obj.refresh_token)
		{
			// we have a refresh token!
			Log("Refreshing session...");

			if (!auth_obj.refresh_token)
			{
				if (callback) callback("No refresh token found!");
				return;
			}

			// request new access_token
			request.post(
				{
					url: urls.oauth,
					form: GetOAuthData({
						"grant_type": 		"refresh_token",
						"refresh_token": 	auth_obj.refresh_token
					})
				},
				function(err, response, body)
				{
					_ParseTokenResponse(err, body, callback);
				}
			);
		}
		else
		{
			// no refresh token, sign-in from scratch
			Log("Signing in with OAuth...");

			// make sure we have an authcode
			if (!auth_obj.auth_code)
			{
				if (callback) callback("No authcode available for OAuth!");
				return;
			}

			// request initial access_token
			request.post(
				{
					url: urls.oauth,
					form: GetOAuthData({
						"grant_type": 	"authorization_code",
						"code": 		auth_obj.auth_code
					})
				},
				function(err, response, body)
				{
					_ParseTokenResponse(err, body, callback);
				}
			);
		}
	}
828696
def get_authorization_url(self,
                              signin_with_twitter=False,
                              access_type=None):
        """"""
        try:
            if signin_with_twitter:
                url = self._get_oauth_url('authenticate')
                if access_type:
                    logging.warning(WARNING_MESSAGE)
            else:
                url = self._get_oauth_url('authorize')
            self.request_token = self._get_request_token(access_type=access_type)
            return self.oauth.authorization_url(url)
        except Exception as e:
            raise TweepError(e)
1225256
def get_authentication_tokens(self):
        
        callback_url = self.callback_url or 'oob'
        request_args = {}
        if OAUTH_LIB_SUPPORTS_CALLBACK:
            request_args['callback_url'] = callback_url

        resp, content = self.client.request(self.request_token_url,
            "GET", **request_args)

        if resp['status'] != '200':
            raise AuthError("Seems something couldn't be verified "\
                "withyour OAuth junk. Error: %s, Message: %s" \
                % (resp['status'], content))

        request_tokens = dict(urlparse.parse_qsl(content))
        oauth_callback_confirmed = request_tokens\
            .get('oauth_callback_confirmed') == 'true'

        if not OAUTH_LIB_SUPPORTS_CALLBACK and callback_url != 'oob'\
            and oauth_callback_confirmed:
            import warnings
            warnings.warn("oauth2 library doesn't support OAuth 1.0a"\
                " type callback, but remote requires it")
            oauth_callback_confirmed = False

        auth_url_params = {'oauth_token': request_tokens['oauth_token']}

        # Use old-style callback argument
        if callback_url != 'oob' and not oauth_callback_confirmed:
            auth_url_params['oauth_callback'] = callback_url

        request_tokens['auth_url'] = self.authenticate_url + '?'\
            + urllib.urlencode(auth_url_params)

        return request_tokens
7708
def _get_token(self, oauth_request, token_type='access'):
        """"""
        token_field = oauth_request.get_parameter('oauth_token')
        token = self.data_store.lookup_token(token_type, token_field)
        if not token:
            raise OAuthError('Invalid %s token: %s' % (token_type, token_field))
        return token
922998
def request_access_token(self, code, redirect_uri=None):
        '''
        
        '''
        redirect = redirect_uri or self._redirect_uri
        resp_text = _http('POST', 'https://graph.qq.com/oauth2.0/token',
                          client_id=self._client_id, client_secret=self._client_secret,
                          redirect_uri=redirect, code=code, grant_type='authorization_code')
        return self._parse_access_token(resp_text)
356512
function(req, res, next) {
    var accessTokenUrl = 'https://github.com/login/oauth/access_token';
    var params = {
      code: req.body.code,
      client_id: req.body.clientId,
      client_secret: config.GITHUB_SECRET,
      redirect_uri: req.body.redirectUri
    };

    request.get({ url: accessTokenUrl, qs: params }, function(err, response, accessToken) {
      if (err) {
        res.status(500).send(err);
        return;
      }
      req.accessToken = qs.parse(accessToken);
      next();
    });
  }
1321933
def get_request_token(self):
        
        print('Obtaining request token')
        try:
            os.remove(os.path.join(self.file_path, 'request_token'))
        except FileNotFoundError:
            pass
        # Create a new session
        session = OAuth1Session(consumer_key=self.consumer_key,
                                consumer_secret=self.consumer_secret)
        # Use the test URL in the GET request
        r = session.request(method='GET',
                            url=self.request_token_url,
                            params={'oauth_callback': 'oob'})
        # If the status code is '200' (OK), proceed
        if r.status_code == 200:
            # Save the JSON-decoded token secret and token
            self.request_token = r.json()['oauth_token']
            self.request_secret = r.json()['oauth_token_secret']
            # Write the token and secret to file
            self.write_token('request_token', self.request_token, self.request_secret)