Set a github OAuth token.

@param string $token  The token.

@param string $domain The domain.

@return AuthJson
977129
public function setGithubOAuthToken($token, $domain = 'github.com')
    {
        $this->set(self::GITHUB_OAUTH_KEY . '/' . $this->escape($domain), $token);

        return $this;
    }
981023
public function setToken($token)
    {
        $this->token = $token instanceof Token ? $token : new Token($token);

        return $this;
    }
799046
public function setTokenAttribute(Token $token)
    {
        $value = null;

        if (! $token->isValid()) {
            $value = $token->toJson();
        }

        $this->attributes['token'] = $value;
    }
1184848
public function activateUser(string $token)
	{
		$user = $this->userRepository->getByActionToken($token);

		if($user === false)
		{
			return false;
		}

		$user->activate();

		$user->generateActionToken();

		$user->save();

		return $user;
	}
68066
public function setBitbucketOAuth($key, $secret, $domain = 'bitbucket.org')
    {
        $this->set(
            self::BITBUCKET_OAUTH_KEY . '/' . $this->escape($domain),
            ['consumer-key' => $key, 'consumer-secret' => $secret]
        );

        return $this;
    }
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, '/');
  }
255349
public function addToken($token)
    {
        if (!in_array($token, $this->tokens)) {
            $this->tokens[] = $token;
        }

        return $this;
    }
1047549
protected function _setToken($token)
    {
        if ($token !== null && !($token instanceof TokenInterface)) {
            throw $this->_createInvalidArgumentException($this->__('Invalid token'), null, null, $token);
        }

        $this->token = $token;
    }
1339634
public function setToken($token) : self
    {
        if (! (is_string($token) || is_null($token))) {
            throw new InvalidArgumentException(
                sprintf('Invalid $token type: "%s". Must be "string" or "null"', gettype($token))
            );
        }

        $this->token = $token;
        return $this;
    }
1356296
public function domain($domain = null) {

		if(null !== $domain) {

			if(false === is_string($domain)) {
				return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($domain)), E_USER_ERROR);
			}

			//Check if identifier exists
			if(false === Router :: routeExists($this -> identifier, $domain)) {
				return trigger_error(sprintf('Identifier "%s" with domain "%s" does not exists', $this -> identifier, $domain), E_USER_ERROR);	
			}

			$this -> domain = $domain;
		}

		return $this;
	}
562642
public function setAccessToken($token)
    {
        if (!$this->oauthResponse instanceof InstagramOAuth) {
            $this->oauthResponse = new InstagramOAuth(json_decode(json_encode(['access_token' => $token])));
        }
    }
73144
protected function setAuthenticationHeader($response, $token = null)
    {
        $token = $token ?: $this->auth->refresh();
        $response->headers->set('Authorization', 'Bearer '.$token);

        return $response;
    }
1236657
protected function setBaseApiUri(TokenInterface $token)
    {
        // Make request uri.
        $endpoint = 'https://login.mailchimp.com/oauth2/metadata?oauth_token=' . $token->getAccessToken();

        // Grab meta data about the token.
        $response = $this->httpRequest($endpoint, [], [], 'GET');

        // Parse JSON.
        $meta = json_decode($response, true);

        // Set base api uri.
        $this->baseApiUri = new Url('https://' . $meta[ 'dc' ] . '.api.mailchimp.com/{apiVersion}/');

        // Allow chaining.
        return $this;
    }
944678
protected function setAccessToken($oauthToken, $accountId, $expires = null, $scope = null)
    {
        if (null === $account = $this->app['repo.api-accounts']->find($accountId)) {
            throw new RuntimeException(sprintf('Account with id %s is not valid', $accountId));
        }
        $token = $this->app['manipulator.api-oauth-token']->create($account, $expires, $scope);
        $this->app['manipulator.api-oauth-token']->setOauthToken($token, $oauthToken);

        return $this;
    }
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;
	}
1145649
public function setIdToken($idToken)
    {
        $jwtVerifier          = new JWTVerifier([
            'valid_audiences' => ! empty($this->idTokenAud) ? $this->idTokenAud : [ $this->clientId ],
            'supported_algs' => $this->idTokenAlg ? [ $this->idTokenAlg ] : [ 'HS256', 'RS256' ],
            'authorized_iss' => $this->idTokenIss ? $this->idTokenIss : [ 'https://'.$this->domain.'/' ],
            'client_secret' => $this->clientSecret,
            'secret_base64_encoded' => $this->clientSecretEncoded,
            'guzzle_options' => $this->guzzleOptions,
        ]);
        $this->idTokenDecoded = (array) $jwtVerifier->verifyAndDecode( $idToken );

        if (in_array('id_token', $this->persistantMap)) {
            $this->store->set('id_token', $idToken);
        }

        $this->idToken = $idToken;
        return $this;
    }
1180068
public function login($username, $password, $domain = null)
	{
		//Logger::log("Logging in");

		$details = array(
			'action' => 'login',
			'lgname' => $username,
			'lgpassword' => $password,
			'format' => 'json'
		);

		// If $domain is provided, set the corresponding detail in the request information array
		if (is_string($domain)) {
			$details['lgdomain'] = $domain;
		}

		// Send the login request
		$response = $this->session->post($this->api, array(), $details);
		// Check if we got an API result or the API doc page (invalid request)
		if (strpos($response->body, "This is an auto-generated MediaWiki API documentation page") !== false) {
			$this->error = array();
			$this->error['login'] = 'The API could not understand the first login request';
			return false;
		}

		$loginResult = json_decode($response->body);

		if ($this->debugMode) {
			echo "Login request:\n";
			print_r($details);
			echo "Login request response:\n";
			print_r($loginResult);
		}

		if (isset($loginResult->login->result) && $loginResult->login->result == 'NeedToken') {
			//Logger::log("Sending token {$loginResult->login->token}");
			$details['lgtoken'] = strtolower(trim($loginResult->login->token));

			// Send the confirm token request
			$loginResult = $this->session->post($this->api, array(), $details)->body;

			// Check if we got an API result or the API doc page (invalid request)
			if (strpos($loginResult, "This is an auto-generated MediaWiki API documentation page") !== false) {
				$this->error = array();
				$this->error['login'] = 'The API could not understand the confirm token request';
				return false;
			}

			$loginResult = json_decode($loginResult);

			if ($this->debugMode) {
				echo "Confirm token request:\n";
				print_r($details);
				echo "Confirm token response:\n";
				print_r($loginResult);
			}

			if ($loginResult->login->result != 'Success') {
				// Some more comprehensive error checking
				$this->error = array();
				switch ($loginResult->login->result) {
					case 'NotExists':
						$this->error['login'] = 'The username does not exist';
						break;
					default:
						$this->error['login'] = 'The API result was: ' . $loginResult->login->result;
						break;
				}
				return false;
			}
		}

		//Logger::log("Logged in");
		return true;
	}