Lines Matching full:token
33 public $token; variable in Google_OAuth2
44 const OAUTH2_TOKEN_URI = 'https://accounts.google.com/o/oauth2/token';
96 // We got here from the redirect from a successful authorization grant, fetch the access token
107 $this->token['created'] = time();
115 …throw new Google_AuthException("Error fetching OAuth2 access token, message: '$response'", $reques…
156 * @param string $token
159 public function setAccessToken($token) { argument
160 $token = json_decode($token, true);
161 if ($token == null) {
162 throw new Google_AuthException('Could not json decode the token');
164 if (! isset($token['access_token'])) {
165 throw new Google_AuthException("Invalid token format");
167 $this->token = $token;
171 return json_encode($this->token);
209 // Cannot sign the request without an OAuth access token.
210 if (null == $this->token && null == $this->assertionCredentials) {
214 // Check if the token is set to expire in the next 30 seconds
220 if (! array_key_exists('refresh_token', $this->token)) {
221 throw new Google_AuthException("The OAuth 2.0 access token has expired, "
222 . "and a refresh token is not available. Refresh tokens are not "
225 $this->refreshToken($this->token['refresh_token']);
231 array('Authorization' => 'Bearer ' . $this->token['access_token'])
238 * Fetches a fresh access token with the given refresh token.
252 * Fetches a fresh access token with a given assertion token.
275 $token = json_decode($body, true);
276 if ($token == null) {
277 throw new Google_AuthException("Could not json decode the access token");
280 if (! isset($token['access_token']) || ! isset($token['expires_in'])) {
281 throw new Google_AuthException("Invalid token format");
284 $this->token['access_token'] = $token['access_token'];
285 $this->token['expires_in'] = $token['expires_in'];
286 $this->token['created'] = time();
288 throw new Google_AuthException("Error refreshing the OAuth2 token, message: '$body'", $code);
293 * Revoke an OAuth2 access token or refresh token. This method will revoke the current access
294 * token, if a token isn't provided.
296 * @param string|null $token The token (access token or a refresh token) that should be revoked.
299 public function revokeToken($token = null) { argument
300 if (!$token) {
301 $token = $this->token['access_token'];
303 $request = new Google_HttpRequest(self::OAUTH2_REVOKE_URI, 'POST', array(), "token=$token");
307 $this->token = null;
319 if (null == $this->token) {
323 // If the token is set to expire in the next 30 seconds.
324 $expired = ($this->token['created']
325 + ($this->token['expires_in'] - 30)) < time();
350 * Verifies an id token and returns the authenticated apiLoginTicket.
351 * Throws an exception if the id token is not valid.
353 * accepted. By default, the id token must have been issued to this OAuth2 client.
361 $id_token = $this->token['id_token'];
371 // Verifies the id token, returns the verified token contents.
376 throw new Google_AuthException("Wrong number of segments in token: $jwt");
384 throw new Google_AuthException("Can't parse token envelope: " . $segments[0]);
387 // Parse token
391 throw new Google_AuthException("Can't parse token payload: " . $segments[1]);
405 throw new Google_AuthException("Invalid token signature: $jwt");
414 throw new Google_AuthException("No issue time in token: $json_body");
425 throw new Google_AuthException("No expiration time in token: $json_body");
435 "Token used too early, $now < $earliest: $json_body");
439 "Token used too late, $now > $latest: $json_body");