Acquire SharePoint Online authentication (FedAuth and rtFa) cookies
@param mixed $token
@throws Exception
554821
protected function acquireAuthenticationCookies($token)
    {
        $urlInfo = parse_url($this->authorityUrl);

        $url =  $urlInfo['scheme'] . '://' . $urlInfo['host'] . self::$SignInPageUrl;
        if ($this->usingFederatedSTS) {
            $url =  $urlInfo['scheme'] . '://' . $urlInfo['host'] . self::$IDCRLSVCPageUrl;

            $headers = array();
            $headers['User-Agent'] = '';
            $headers['X-IDCRL_ACCEPTED'] = 't';
            $headers['Authorization'] = 'BPOSIDCRL ' . $token;
            $headers['Content-Type'] = 'application/x-www-form-urlencoded';

            $response = Requests::head($url,$headers,true);
            $cookies = Requests::parseCookies($response);
            $this->SPOIDCRL = $cookies['SPOIDCRL'];
        }
        else {
            $response = Requests::post($url,null,$token,true);
            $cookies = Requests::parseCookies($response);
            $this->FedAuth = $cookies['FedAuth'];
            $this->rtFa = $cookies['rtFa'];
        }
    }
189158
public function tokenLoginAction($token)
    {
        $newSessionId = $this->loginTokenCache->get($token);
        $this->loginTokenCache->remove($token);

        if ($newSessionId === false) {
            $this->systemLogger->log(sprintf('Token-based login failed, non-existing or expired token %s', $token), LOG_WARNING);
            $this->redirect('index');
        }

        $this->systemLogger->log(sprintf('Token-based login succeeded, token %s', $token), LOG_DEBUG);

        $newSession = $this->sessionManager->getSession($newSessionId);
        if ($newSession->canBeResumed()) {
            $newSession->resume();
        }
        if ($newSession->isStarted()) {
            $newSession->putData('lastVisitedNode', null);
        } else {
            $this->systemLogger->log(sprintf('Failed resuming or starting session %s which was referred to in the login token %s.', $newSessionId, $token), LOG_ERR);
        }

        $this->replaceSessionCookie($newSessionId);
        $this->redirect('index', 'Backend\Backend');
    }
24253
public function setAuthorizerAccessToken($token, $expires = 7200)
    {
        return $this->cache->save($this->getAuthorizerAccessTokenKey(), $token, $expires);
    }
492646
public function setAuthToken($token)
    {
        $this->apiClient
            ->setShopId(null)
            ->setShopPassword(null)
            ->setBearerToken($token);

        return $this;
    }
597745
public function AccessToken($Token = NULL, $Secret = NULL) {
      if (!$this->IsConfigured()) 
         return FALSE;
      
      if (is_object($Token)) {
         $this->_AccessToken = $Token;
      } if ($Token !== NULL && $Secret !== NULL) {
         $this->_AccessToken = new OAuthToken($Token, $Secret);
//         setcookie('tw_access_token', $Token, 0, C('Garden.Cookie.Path', '/'), C('Garden.Cookie.Domain', ''));
      } elseif ($this->_AccessToken == NULL) {
//         $Token = GetValue('tw_access_token', $_COOKIE, NULL);
         if ($Token)
            $this->_AccessToken = $this->GetOAuthToken($Token);
         elseif (Gdn::Session()->User) {
            $AccessToken = GetValueR(self::ProviderKey.'.AccessToken', Gdn::Session()->User->Attributes);
            
            if (is_array($AccessToken)) {
               $this->_AccessToken = new OAuthToken($AccessToken[0], $AccessToken[1]);
            }
         }
      }
      return $this->_AccessToken;
   }
922752
public function setAccessToken($token)
    {
        if ($token instanceof Token\TokenInterface) {
            $this->rawToken = $token;
        } else {
            $this->rawToken = is_array($token) ?
                $this->tokenFactory($token) :
                $this->tokenFactory(['access_token' => $token]);
        }

        if ($this->rawToken === null) {
            throw new Exception\OAuth2Exception("setAccessToken() takes a string, array or TokenInterface object");
        }

        return $this;
    }
1064350
protected function storeToken(string $token)
    {
        $cookies = $this->getCookies();
        $cookies['token']['domain'] = '.doodle.com';
        $cookies['token']['truefalse'] = 'TRUE';
        $cookies['token']['path'] = '/';
        $cookies['token']['truefalse2'] = 'FALSE';
        $cookies['token']['something'] = '0';
        $cookies['token']['name'] = 'Token';
        $cookies['token']['value'] = $token;
        $cookies['d-betaCode'] = $cookies['DoodleAuthentication'];
        $cookies['d-betaCode']['name'] = 'd-betaCode';
        $cookies['d-betaCode']['value'] = true;
        $cookies['d-forceBeta'] = $cookies['DoodleAuthentication'];
        $cookies['d-forceBeta']['name'] = 'd-forceBeta';
        $cookies['d-forceBeta']['value'] = false;
        $this->persistCookies($cookies);
        $this->token = $token;
    }
824123
public function getActivationLink(Token $token)
    {
        $activationConfiguration = $token->getPreset()['activation'];
        $tokenHash = $token->getHash();

        if ($activationConfiguration['uri'] === null) {
            throw new \RuntimeException('Building activation link failed, no uri configuration is set', 1434728943);
        } elseif (is_array($activationConfiguration['uri'])) {
            $routerConfiguration = $activationConfiguration['uri'];

            $this->uriBuilder->setRequest($this->request);
            $uri = $this->uriBuilder
                ->setCreateAbsoluteUri(true)
                ->setFormat($routerConfiguration['@format'])
                ->uriFor(
                    $routerConfiguration['@action'],
                    $routerConfiguration['arguments'],
                    $routerConfiguration['@controller'],
                    $routerConfiguration['@package'],
                    $routerConfiguration['@subpackage']
                );
        } elseif (is_string($activationConfiguration['uri'])) {
            $uri = $activationConfiguration['uri'];
        } else {
            throw new \RuntimeException('Building activation link failed, uri configuration is invalid (neither array nor string)', 1434732898);
        }

        $this->logger->log(sprintf('Activation link built for token with hash %s', $tokenHash, $token->getIdentifier()), LOG_INFO);

        return str_replace('-tokenhash-', $tokenHash, $uri);
    }
1015589
public function acquireToken($parameters)
    {
        $realm = $this->getRealmFromTargetUrl();
        $urlInfo = parse_url($this->url);
        $this->accessToken = $this->getAppOnlyAccessToken($urlInfo["host"],$realm);
    }
1123262
public function setToken($token) {
    // check passed data
    if(!is_null($token) && !is_array($token)) {
      // bad data passed
      throw new LinkedInException('LinkedIn->setToken(): bad data passed, $token_access should be in array format.');
    }
    
    // set token
    $this->token = $token;
	}
980511
public function getByActionToken(string $token)
	{
		return $this->setAuthorizer($this->getModel()->where('action_token', '=', $token)->first());
	}
39434
public function setAccessToken($token)
    {
        /**
         * @var Client $google
         */
        $google = Container::getInstance()->make(Client::class);

        $google->getCache()->clear();

        $google->setAccessToken($token);

        if (isset($token['refresh_token']) and $google->isAccessTokenExpired()) {
            $google->fetchAccessTokenWithRefreshToken();
        }

        return $this->setService($google->make('sheets'))
                    ->setDriveService($google->make('drive'));
    }
33798
protected function getTokenFormatter($token)
    {
        $formatters = $this->getTokenFormatters();

        if (!array_key_exists($token, $formatters)) {
            $message = "The class %s does not know how to format the %s token\n".
                       "Have you added it in the getTokenFormatters() method?";

            throw new Exception(sprintf($message, get_called_class(), $token));
        }

        return $formatters[$token];
    }
1018123
public function setAccessToken($token = NULL, $expire = 0) {
    if (!empty($expire)) {
      $expire = REQUEST_TIME + $expire;
    }

    if (isset(\Drupal::request()->cookies)) {
      \Drupal::request()->cookies->set('Drupal_visitor_' . $this->accessTokenCookie, $token);
    }

    setrawcookie('Drupal.visitor.' . $this->accessTokenCookie, rawurlencode($token), $expire, '/');
  }
530865
public function decode($token)
    {
        $decoded = json_decode($token, true);

        if (is_array($decoded) === true &&
            array_key_exists(self::KEY_USER_ID, $decoded) === true &&
            array_key_exists(self::KEY_SECRET, $decoded) === true
        ) {
            $token  = $decoded[self::KEY_SECRET];
            $userId = intval($decoded[self::KEY_USER_ID]);
            /** @var User $user */
            $user   = (new User())->query()->find($userId);

            if ($user !== null && $user->{User::FIELD_API_TOKEN} === $token) {
                $account = new Account($user, [Account::ATTR_ID => $userId]);

                $this->getLogger()->debug('Account authenticated.', [User::FIELD_ID => $userId]);

                return $account;
            }
        }

        return new Anonymous();
    }
562642
public function setAccessToken($token)
    {
        if (!$this->oauthResponse instanceof InstagramOAuth) {
            $this->oauthResponse = new InstagramOAuth(json_decode(json_encode(['access_token' => $token])));
        }
    }
109274
public function getFromToken( $Token){
        $rest = $this->getService( self::API_SHARE_LINK . $Token);
        $rest->GET();

        return $rest->getResult( models\FileSystem\ShareLink::class);
    }