Return `access_token` fields for OAuth2, and add `id_token` fields for
        OpenID Connect according to the `access_token` scope.
180847
def access_token_response_data(self, access_token, response_type=None, nonce=''):
        

        # Clear the scope for requests that do not use OpenID Connect.
        # Scopes for pure OAuth2 request are currently not supported.
        scope = constants.DEFAULT_SCOPE

        extra_data = {}

        # Add OpenID Connect `id_token` if requested.
        #
        # TODO: Unfourtunately because of how django-oauth2-provider implements
        # scopes, we cannot check if `openid` is the first scope to be
        # requested, as required by OpenID Connect specification.

        if provider.scope.check(constants.OPEN_ID_SCOPE, access_token.scope):
            id_token = self.get_id_token(access_token, nonce)
            extra_data['id_token'] = self.encode_id_token(id_token)
            scope = provider.scope.to_int(*id_token.scopes)

        # Update the token scope, so it includes only authorized values.
        access_token.scope = scope
        access_token.save()

        # Get the main fields for OAuth2 response.
        response_data = super(AccessTokenView, self).access_token_response_data(access_token)

        # Add any additional fields if OpenID Connect is requested. The order of
        # the addition makes sures the OAuth2 values are not overrided.
        response_data = dict(extra_data.items() + response_data.items())

        return response_data
642409
def get_access_token(self) -> str:
        
        if self._service_token:
            return self._service_token
        if self._app_id and self._login and self._password:
            try:
                if self.login():
                    url_params = self.auth_oauth2()
                    if 'access_token' in url_params:
                        return url_params['access_token']
            finally:
                self.close()
1155681
def access_token(self):
        """"""
        if self.cache_token:
            return self.access_token_ or \
                   self._resolve_credential('access_token')
        return self.access_token_
468273
def get_sns_token openid, persistent_code
      path = "/sns/get_sns_token?access_token=#{refreshed_access_token}"
      fire_request path, {openid: openid, persistent_code: persistent_code}
    end
1262843
def request_access_token(self, access_code):
        ""
        token_response = request_session.post(
            "https://github.com/login/oauth/access_token",
            data={
                "client_id": self.oauth_client_id,
                "client_secret": self.oauth_client_secret,
                "code": access_code
            },
            headers={"Accept": "application/json"},
        )
        return helper_request_access_token(token_response.json())
674696
def get_access_token(self, code, state=None):
        '''
        
        '''
        kw = dict(client_id=self._client_id, client_secret=self._client_secret, code=code)
        if self._redirect_uri:
            kw['redirect_uri'] = self._redirect_uri
        if state:
            kw['state'] = state
        opener = build_opener(HTTPSHandler)
        request = Request('https://github.com/login/oauth/access_token', data=_encode_params(kw))
        request.get_method = _METHOD_MAP['POST']
        request.add_header('Accept', 'application/json')
        try:
            response = opener.open(request, timeout=TIMEOUT)
            r = _parse_json(response.read())
            if 'error' in r:
                raise ApiAuthError(str(r.error))
            return str(r.access_token)
        except HTTPError as e:
            raise ApiAuthError('HTTPError when get access token')
1318029
def obtain_access_token(self):
        
        if self.oauth_version != 2:
            raise TwythonError('This method can only be called when your \
                               OAuth version is 2.0.')

        data = {'grant_type': 'client_credentials'}
        basic_auth = HTTPBasicAuth(self.app_key, self.app_secret)
        try:
            response = self.client.post(self.request_token_url,
                                        data=data, auth=basic_auth)
            content = response.content.decode('utf-8')
            try:
                content = content.json()
            except AttributeError:
                content = json.loads(content)
                access_token = content['access_token']
        except (KeyError, ValueError, requests.exceptions.RequestException):
            raise TwythonAuthError('Unable to obtain OAuth 2 access token.')
        else:
            return access_token
262186
def extend_access_token(self, app_id, app_secret):
        
        args = {
            "client_id": app_id,
            "client_secret": app_secret,
            "grant_type": "fb_exchange_token",
            "fb_exchange_token": self.access_token,
        }

        return self.request(
            "{0}/oauth/access_token".format(self.version), args=args
        )
743945
def oauth_token_create(self, data, **kwargs):
        ""
        api_path = "/api/v2/oauth/tokens.json"
        return self.call(api_path, method="POST", data=data, **kwargs)
710333
function generateAccessToken(req, res, next) {
        /**
         * TODO:
         * https://github.com/jaredhanson/oauth2orize/issues/182
         * oauth2orize only offers the option to forward request information via authInfo object
         *
         * Important: only used for resetting the brute count (access to req.ip)
         */
        req.authInfo = {
            ip: req.ip,
            accessToken: authUtils.getBearerAutorizationToken(req)
        };

        return oauthServer.token()(req, res, function (err) {
            if (err && err.status === 400) {
                err = new common.errors.BadRequestError({err: err, message: err.message});
            }

            next(err);
        });
    }
764938
def get_id_token(self, access_token, nonce):
        

        claims_string = self.request.POST.get('claims')
        claims_request = json.loads(claims_string) if claims_string else {}

        return oidc.id_token(access_token, nonce, claims_request)
514523
def get_access_token(self, refresh_token):
        

        token = requests.post(GOOGLE_OAUTH2_TOKEN_URL, data=dict(
            refresh_token=refresh_token,
            grant_type='refresh_token',
            client_id=self.client_id,
            client_secret=self.client_secret,
        )).json()

        if not token or token.get('error'):
            return

        return token
824456
public function getOauthUserinfo($access_token,$openid){
        $result = $this->http_get(self::API_BASE_URL_PREFIX.self::OAUTH_USERINFO_URL.'access_token='.$access_token.'&openid='.$openid);
        if ($result)
        {
            $json = json_decode($result,true);
            if (!$json || !empty($json['errcode'])) {
                $this->errCode = $json['errcode'];
                $this->errMsg = $json['errmsg'];
                return false;
            }
            return $json;
        }
        return false;
    }
1124519
def request_access_token(self, params):
        
        return self.request(self.access_token_url, method="GET", params=params)
348385
public static BaseResult auth(String access_token,String openid){
		HttpUriRequest httpUriRequest = RequestBuilder.get()
				.setUri(BASE_URI + "/sns/auth")
				.addParameter(PARAM_ACCESS_TOKEN, API.accessToken(access_token))
				.addParameter("openid", openid)
				.build();
		return LocalHttpClient.executeJsonResult(httpUriRequest,BaseResult.class);
	}
1148886
public static UserInfoList userInfoBatchget(String access_token,String lang,List<String> openids){
		return userInfoBatchget(access_token, lang, openids,0);
	}
635118
def get_access_token(self):
        
        if self.token_info and not self.is_token_expired(self.token_info):
            return self.token_info['access_token']

        token_info = self._request_access_token()
        token_info = self._add_custom_values_to_token_info(token_info)
        self.token_info = token_info
        return self.token_info['access_token']