Search code examples
postgoogle-apigoogle-oauth

What does Google OAuth 2.0 for Devices "expires_in", "interval" mean?


On googles developers page, https://developers.google.com/identity/protocols/OAuth2ForDevices, it states that:

{
  "device_code" : "4/4-GMMhmHCXhWEzkobqIHGG_EnNYYsAkukHspeYUk9E8",
  "user_code" : "GQVQ-JKEC",
  "verification_url" : "https://www.google.com/device",
  "expires_in" : 1800,
  "interval" : 5
}

Is returned after a succesful request for a user code. When it says "1800" for expires_in, does it mean minutes, hours? And what is intervals? I tried reading all of Google material but I didn't find anything more about the details about the two.

Update

As for interval I didnt look closely enough, it states on the same page:

Your application should repeat these requests at the rate that does not exceed the value of interval field.

So the interval is the rate in which I must poll the google server, to check if the user has authorized with the user code yet. Maybe I missed what the expires_in variable is as well.


Solution

  • In a system like this, the goal is to have the user see the code in your system and enter it in a webpage of their own.

    The interval, as you noted, is how often you can check with Google to see if the user has approved your request.

    expires_in appears to let you know how long the user has to complete this action, after which the attempt to login didn't work. This isn't outright stated, but it's parallels with the expires_in of the later token response strongly suggest that this is how it works.