Gets a user access token.
338701
protected function getAccessToken() {
    $cookies = $_COOKIE;

    if (isset(\Drupal::request()->cookies)) {
      $cookies = \Drupal::request()->cookies->all();
    }

    $cookie_name = 'Drupal_visitor_' . $this->accessTokenCookie;

    if (isset($cookies[$cookie_name])) {
      return $cookies[$cookie_name];
    }

    return NULL;
  }
459723
def _obtain_api_token(self, username, password):
        """"""
        data = self._request("POST", "auth/apitoken",
                             {"username": username, "password": password},
                             reestablish_session=False)
        return data["api_token"]
784076
def get_token(self):
        """"""
        auth_resp = self.get_auth()

        if auth_resp['status'] == 'mfa_req':
            token_resp = self.get_mfa(auth_resp)
        else:
            token_resp = auth_resp

        token = token_resp['data']['client_token']['client_token']
        return token
1348313
def request(self, method, url, **kwargs):
        """"""
        user_token = kwargs.pop('token', self.token)
        token, secret, expires_at = self.parse_raw_token(user_token)
        if token is not None:
            params = kwargs.get('params', {})
            params['access_token'] = token
            kwargs['params'] = params
        return super(OAuth2Provider, self).request(method, url, **kwargs)
1069547
public function getAccessToken() {
        if (!empty($this->accessToken)) {
            return $this->accessToken;
        }
        $accessToken = $this->sessionStorage->read('access_token');
        if (!empty($accessToken)) {
            $this->accessToken = $accssToken;
            return $this->accessToken;
        }

        $this->exchangeToken();

        return $this->accessToken;
    }
334409
def get(self):
    """"""
    try:
      app_user = InitUser()

      if (app_user.client_id and app_user.client_secret and
          app_user.adwords_manager_cid and app_user.developer_token and
          app_user.refresh_token):
        self.redirect('/showAccounts')
      else:
        self.redirect('/showCredentials')
    except Exception, e:
      logging.debug(str(e))
1175934
private AccessToken getAccessToken() throws IOException {
    // synchronize attempts to refresh the accessToken
    synchronized (credentials) {
      if (needsRefresh(credentials.getAccessToken())) {
        credentialRefresher.refresh(credentials);
      }
    }
    return credentials.getAccessToken();
  }
504489
private static Token<EsTokenIdentifier> getAuthToken(ClusterName clusterName, User user) {
        EsToken esToken = getEsAuthToken(clusterName, user);
        if (esToken == null) {
            return null;
        } else {
            return EsTokenIdentifier.createTokenFrom(esToken);
        }
    }
693255
public function getAccessToken()
    {
        $session = $this->getClient()->getConnector()->getSession();
        $token = $session->get('accessToken');
        $expires = $session->get('expires');
        if (!$token || $expires < time()) {
            // Force a connection to the API to ensure there is an access token.
            $this->getMyAccount(true);
            if (!$token = $session->get('accessToken')) {
                throw new \RuntimeException('No access token found');
            }
        }

        return $token;
    }
1249764
public function getCurrentUser()
    {
        if ($token = $this->tokenStorage->getToken()) {
            if (($user = $token->getUser()) && is_object($user)) {
                return $user;
            }
        }

        throw new \Exception('Authorization needed', ErrorCode::CODE_UNAUTHORIZED);
    }
192004
def _get_access_from_refresh(self) -> Tuple[str, float]:
        
        headers = self._get_authorization_headers()
        data = {
            'grant_type': 'refresh_token',
            'refresh_token': self.refresh_token
        }
        r = self.session.post(self.TOKEN_URL, headers=headers, data=data)
        response_data = r.json()
        return (response_data['access_token'], response_data['expires_in'])
800073
def session_token(self):
        """"""
        session_token = None
        if self.user_id is not None:
            session_token = token_getter(self.remote)
        if session_token:
            token = RemoteToken.get(
                self.user_id, self.remote.consumer_key,
                access_token=session_token[0]
            )
            return token
        return None
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
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']
335784
public static function getAccessToken()
    {
        if (static::$token) {
            return static::$token;
        }
        $response = static::$httpClient->post(static::GET_TOKEN_ENDPOINT, [
            'form_params' => [
                'client_id' => static::$apiContext->getClientId(),
                'client_secret' => static::$apiContext->getClientSecret(),
                'grant_type' => 'silent',
                'kdt_id' => static::$apiContext->getKdtId(),
            ]
        ]);
        $json = \GuzzleHttp\json_decode((string) $response->getBody(), true);
        $expiresAt = new \DateTime($json['expires_in'] . ' seconds');

        return static::$token = new Token($json['access_token'], $expiresAt);
    }
1023604
def get_token_credentials(cls, username, request):
        
        try:
            user = cls.get_item(username=username)
        except Exception as ex:
            log.error(str(ex))
            forget(request)
        else:
            if user:
                return user.api_key.token
739289
def _get_at_from_session(self):
        
        try:
            return self.request.session['oauth_%s_access_token'
                                        % get_token_prefix(
                                            self.request_token_url)]
        except KeyError:
            raise OAuthError(
                _('No access token saved for "%s".')
                % get_token_prefix(self.request_token_url))