R
R
robert_n2016-02-04 12:50:15
Google
robert_n, 2016-02-04 12:50:15

What is the lifetime of token Google Api?

Hello!
I can't figure out what is the lifetime of the token that I get from Google. Sending a token for verification:

$token_data = $client->verifyIdToken($access_token);

I get a response:
"iss": "https://accounts.google.com",
 "sub": "110169484474386276334",
 "azp": "1008719970978-hb24n2dstb40o45d4feuo2ukqmcc6381.apps.googleusercontent.com",
 "aud": "1008719970978-hb24n2dstb40o45d4feuo2ukqmcc6381.apps.googleusercontent.com",
 "iat": "1433978353",
 "exp": "1454526850",

 // These seven fields are only included when the user has granted the "profile" and
 // "email" OAuth scopes to the application.
 "email": "[email protected]",
 "email_verified": "true",
 "name" : "Test User",
 "picture": "https://lh4.googleusercontent.com/-kYgzyAWpZzJ/ABCDEFGHI/AAAJKLMNOP/tIXL9Ir44LE/s99-c/photo.jpg",
 "given_name": "Test",
 "family_name": "User",
 "locale": "en"

Interested in the field "exp" . Here it is written that the lifetime of the token is indicated in seconds. But if you translate 1454526850 seconds into years, for example, then you get 46 years. But for now, I note that the token becomes invalid after about 30 minutes or an hour (need to test). In general, please tell me how long it lasts!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey, 2016-02-04
@robert_n

As Maxim Creative correctly said , data on the life of the token is given in the timestamp format.

// Получаем данные о пользователе
$token_data = $client->verifyIdToken($access_token);
// Время создания токена
$iat = $token_data['iat'];
// Время окончания действия токена
$exp = $token_data['exp'];	
// Выводим время начала и окончания действия токена			
echo date('Y-m-d H:i', $iat)."  --  ".date('Y-m-d H:i', $exp);

Let's say you get this response:
"iat": 1454588648
"exp": 1454592248

Then after executing the previous code, you will see:
From here we get the lifetime of the token equal to 1 hour.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question