mattga / goauth2

Automatically exported from code.google.com/p/goauth2
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Invalid datetime returned for Facebook/etc. #12

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Used it with facebook API, check expire date.

What is the expected output? What do you see instead?
invalid date, out of date range.

What version of the product are you using? On what operating system?
latest release of Go, Ubuntu server 12.04lts 64bit

Please provide any additional information below.

this line
b.ExpiresIn, _ = time.ParseDuration(vals.Get("expires") + "s")

and this
tok.Expiry = time.Now().Add(b.ExpiresIn * time.Second)

the 1st line should suffix with "ns" to be compatible with the 2nd line.

Thanks.

Original issue reported on code.google.com by akmal...@gmail.com on 13 Jan 2013 at 1:41

GoogleCodeExporter commented 8 years ago
That's nto how time.Duration and ParseDuration work. A time.Duration is always 
in nanoseconds (to avoid precisely this kind of confusion). The "expires" field 
of the HTTP response should be in seconds, as per the spec, so that's why we 
append "s" to the value before parsing it.

The problem you're seeing is because Facebook do not return an "expires" value 
or a refresh token. You just need to re-authenticate each time.

Original comment by a...@google.com on 13 Jan 2013 at 8:56

GoogleCodeExporter commented 8 years ago

Original comment by a...@golang.org on 13 Jan 2013 at 8:56