Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In oauth2, is expires_in is in seconds or miliseconds?

Tags:

oauth-2.0

I got this sort of thing in oauth2

{
  "token_type": "Bearer",
  "expires_in": 43200,
  "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjExMzk2NGY3MDZiNGM0ZTJhYTFiM2M4NGQ1Y2YwYWRhMjA4OWIwNDc2ZjM3NjlhN2I1ZTBmZDNkN2YyM2IxYmUxNWE0N2Y0YTU4YmYzMzE1In0.eyJhdWQiOiIxNDQiLCJqdGkiOiIxMTM5NjRmNzA2YjRjNGUyYWExYjNjODRkNWNmMGFkYTIwODliMDQ3NmYzNzY5YTdiNWUwZmQzZDdmMjNiMWJlMTVhNDdmNGE1OGJmMzMxNSIsImlhdCI6MTU1NDc4NzQ3MSwibmJmIjoxNTU0Nzg3NDcxLCJleHAiOjE1NTQ4MzA2NzEsInN1YiI6IjMxOTgwMSIsInNjb3BlcyI6WyJ0cmFkZSIsInByb2ZpbGUiXX0.blR3PYblZtYvd0VOnaePaUFu_dkE2yhbGgBLTHqXGuvaMC-57OhXaWNxLLjLzlHrL1bTJcMUYfRrBNhbpiLe9ln7FofuoRUfSm0IhBuvgX-5Le1k0KLd-1JdFW8Y1jIOYm8jGT7WdBRD3ykPoWAKcp_iuXgv2Ci_beii6W6ANX4BWShpekBuUfcKQoiXLNpmDWNt8SfbF4MDjDCs-Z81HAtzFr4P7lmMFugkqODOgVYg9VEhAdXWG56K8uTBmdc0v7w1Ahy7DE_wWzOMOA6JPq6qUvoIuz51I7LCLLhXUNeLXpELuXzREKqSbgZJb2KaZ67vbFYEM4dt8s67SKWfMv5KK7OPY6v0zB529m3r5H0wfvNOH7PNw782q9AmOSZc62yXCKijBNP-7XKsrzbK2LneVn8z_wDLJ3xjs7frppkQ0f-YAk3xmg8JJnPWDleLm4FUx32F2_MwPlN227ThgASi2N8jtRpkUgNFnOkBScDhEwpT5zqJK9H09pTkUIWdDCB7H5er0HR9qBK509qif4b9UGl1OHMnjQKyFQT36c5nGJCG05E0IRH8Mbax37Wv94Eb_53rpJwEWv_XkuT-N_wPEwf92VvwCUhoHxTK9a-p78NfCuroRQWARk4gdhZ9i_rCgQQEzlEk9EsiFl_bTcBgT7bU",
  "refresh_token": "def5020046875925bb9c0ba2ead1954836339f8f31d5a45103603b857567096da0eb820114a75a6ed3db9eb301e3389d284a696a3cb21ea0df9eebdca2052e8b8120423bb2d4b063651aeff7ac7623ea3beea2f3f21b5127792daf6f71f4d23980ca140f875ec5607f63deeac8696128ea2918a473486c0c4223a088f385046b84e6f8edd17cb459d5cdc66d856ee42b2ce3f90f3829a104735372ac14eae3ccff71dde4552b9ad46df7380870b5cd3bcb8d6ca7f16484a2d5b3b26efcebf7b2e5221ed16620445099ee4b0239fd82c8e7f37262883d57fc6545ab31f9e52dc4fc4de70235d5121f7222f8066bfdc9945aa9ac5940c6e2fdc9daa6623a9f2b6e3f41aa47698ec1008514878494fef9932b317f42873af44d5dbcdd19958c2fc3835a820d09e5aa6a6ae3bef6592812a698b2547f0cca5e9f8ac38014b6651be46a098374f92bc35fcebc373f17ab70fd20cf1147bf11e2093e9908516717a3902d2d9efc7f06e917fb67dca2bca4f0c25ed7",
  "expire": 1554787516031
}

I changed the access token and refresh token a bit

Now there is expires_in 43200. Is that second or milisecond or years or what?

I used this code

Public Shared Function currentTimeStamp() As Int64
    Dim utime = (DateTime.UtcNow - unixEpoch()).TotalMilliseconds
    Return CLng(utime)
End Function

    Dim jtoken1 = JToken.Parse(jtoken2)
    Dim accesstoken = jtoken1.Item("access_token")
    Dim expirytime = jtoken1.Item("expires_in")
    Dim currentTimeStamp = jsonHelper.currentTimeStamp()
    Dim timeexpire = currentTimeStamp + CLng(expirytime)
    Dim refreshtoken = jtoken1.Item("refresh_token").ToString
    jtoken1.Item("expire") = timeexpire

That seems to be a bit wrong.

Is there any documentation that can clearly says it's seconds or milliseconds?

like image 700
user4951 Avatar asked Apr 10 '19 15:04

user4951


People also ask

What is Expires_in?

Expires_in is a OAuth Parameters Registry and is RECOMMENDED to be used to indicate the lifetime in seconds of the Access Token. For example, the value "3600" denotes that the access token will expire in one hour from the time the response was generated.

How long is OAuth token?

The access token is set with a reasonably lower expiration time of 30 mins. The refresh token is set with a very long expiration time of 200 days. If the traffic to this API is 10 requests/second, then it can generate as many as 864,000 tokens in a day.

Which format does OAuth 2.0 require tokens to use?

Bearer Tokens are the predominant type of access token used with OAuth 2.0. A Bearer Token is an opaque string, not intended to have any meaning to clients using it. Some servers will issue tokens that are a short string of hexadecimal characters, while others may use structured tokens such as JSON Web Tokens.

What is OAuth2 standard?

OAuth 2.0, which stands for “Open Authorization”, is a standard designed to allow a website or application to access resources hosted by other web apps on behalf of a user. It replaced OAuth 1.0 in 2012 and is now the de facto industry standard for online authorization.


1 Answers

expires_in is value in seconds

like image 124
Avinash Singh Avatar answered Nov 07 '22 23:11

Avinash Singh