Return type of Token (A=Access code, T=Token, R=Refresh token) and
        the session id.

        :param token: A token
        :return: tuple of token type and session id
423263
def info(self, token):
        
        verifier = JWT(key_jar=self.key_jar, allowed_sign_algs=[self.alg])
        _payload = verifier.unpack(token)
        if is_expired(_payload['exp']):
            raise ToOld('Token has expired')
        return _payload['sid'], _payload['ttype']
1215605
def _get_token_from_headers(self, request, refresh_token):
        
        header = request.headers.get(self.config.authorization_header(), None)

        if header is None:
            return None

        else:
            header_prefix_key = "authorization_header_prefix"
            header_prefix = getattr(self.config, header_prefix_key)
            if header_prefix():
                try:
                    prefix, token = header.split(" ")
                    if prefix != header_prefix():
                        raise Exception

                except Exception:
                    raise exceptions.InvalidAuthorizationHeader()

            else:
                token = header

            if refresh_token:
                token = request.json.get(self.config.refresh_token_name())

            return token
1050105
def get_token(self):
        
        if not self.authenticated:
            raise ValueError("Must authenticate() as a client first.")

        # If token has expired we'll need to refresh and get a new
        # client credential
        if self.is_expired_token(self.client):
            logging.info("client token expired, will need to refresh token")
            self.authenticate(self.client['id'], self.client['secret'],
                    use_cache=False)

        return self.client['access_token']
561760
def client_id_from_id_token(id_token):
    
    payload = JWT().unpack(id_token).payload()
    aud = payload.get('aud', None)
    if aud is None:
        return None
    if isinstance(aud, list):
        return aud[0]
    return aud
545531
private String getRefreshToken(Token accessToken) {
    JSONObject rawJson = JSONObject.fromObject(accessToken.getRawResponse());
    return rawJson.getString("refresh_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
719295
def refresh_token(self, refresh_token):
        

        response = requests.post('%saccess_token' % OAUTH_URL, {
                                 'refresh_token': refresh_token,
                                 'grant_type': 'refresh_token',
                                 'client_id': self.client_id,
                                 'client_secret': self.client_secret
                                 })
        resp = json.loads(response.content)

        if 'access_token' in resp:
            self.token = resp['access_token']

        return resp
1018030
def client_tokens(self):
        
        client_id, client_secret = self.get_auth_basic()
        if not client_id and not client_secret:
            client_id = self.query_kwargs.get('client_id', '')
            client_secret = self.query_kwargs.get('client_secret', '')
            if not client_id and not client_secret:
                client_id = self.body_kwargs.get('client_id', '')
                client_secret = self.body_kwargs.get('client_secret', '')

        return client_id, client_secret
317671
async def refresh_token(self, refresh_token):
        
        async with self._client_session() as client:
            well_known = await self._get_well_known(client)

            try:
                return await self._post(
                    client,
                    well_known['token_endpoint'],
                    data={
                        'grant_type': GRANT_TYPE_REFRESH_TOKEN,
                        'refresh_token': refresh_token,
                    }
                )
            except aiohttp.ClientResponseError as e:
                raise ConfigException('oidc: failed to refresh access token')
10379
def get_request_token(self):
        
        
        if self._request_token is None:
            self._request_token = self._get_request_token()
        return self._request_token
675566
def refresh_access_token(self, refresh_token):
        ''' 
        '''
        request = self._get_request()
        response = request.post(self.OAUTH_TOKEN_URL, {
            "grant_type": "refresh_token",
            "refresh_token": refresh_token
        })
        self.auth = HSAccessTokenAuth.from_response(response)
        return self.auth.access_token
660479
def get_token(self, code=None):
        ''' 
        '''
        tokenobj = self.steemconnect().get_access_token(code)
        for t in tokenobj:
            if t == 'error':
                self.msg.error_message(str(tokenobj[t]))
                return False
            elif t == 'access_token':
                self.username = tokenobj['username']
                self.refresh_token = tokenobj['refresh_token']
                return tokenobj[t]
766444
def t_ANY_ID(self, token):
        '
        if token.value in self.KEYWORDS:
            if (token.value == 'annotation_type') and self.cur_indent:
                # annotation_type was added as a reserved keyword relatively
                # late, when there could be identifers with the same name
                # in existing specs. because annotation_type-the-keyword can
                # only be used at the beginning of a non-indented line, this
                # check lets both the keyword and the identifer coexist and
                # maintains backward compatibility.
                # Note: this is kind of a hack, and we should get rid of it if
                # the lexer gets better at telling keywords from identifiers in general.
                return token
            token.type = self.RESERVED.get(token.value, 'KEYWORD')
            return token
        else:
            return token
447111
def refresh():
    
    old_token = guard.read_token_from_header()
    new_token = guard.refresh_jwt_token(old_token)
    ret = {'access_token': new_token}
    return flask.jsonify(ret), 200
416725
def token_auth(self, token):
        
        if not token:
            return

        self.headers.update({
            'Authorization': 'token {0}'.format(token)
            })
        # Unset username/password so we stop sending them
        self.auth = None
1152963
def _check_token_cache_type(self, cache_value):
        '''
        
        '''
        def check_string_value(name):
            return (
                isinstance(cache_value[name], str) or
                isinstance(cache_value[name], unicode)
            )

        def check_refresh_token():
            if 'refresh' in cache_value:
                return check_string_value('refresh')
            else:
                return True

        return (
            isinstance(cache_value, dict) and
            'token' in cache_value and
            'expires' in cache_value and
            check_string_value('token') and
            isinstance(cache_value['expires'], float) and
            check_refresh_token()
        )
275519
def token(self):
        
        if self._token is None:
            token_type = os.getenv(TOKEN_TYPE_KEY, '')
            token_body = os.getenv(TOKEN_BODY_KEY, '')
            self._token = _Token(token_type, token_body)
        return self._token