happydpc / goauth2

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

Use content-type detection #11

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Trying to auth with GitHub. Since no `Accept` header can set in the request, 
GitHub will default to urlencoding for the answer. Simply supporting both, json 
and urlencoding, and switching over the `Content-Type` header is a viable 
solution.

I tested it with GitHub and Google. As far as I can tell it should also fix the 
"Facebook problem" without ludicrous solutions like hardcoding hostnames[1].

[1]: 
https://github.com/robfig/goauth2/commit/c649965654aa4d41f076735d2df236066a37d2b
9#L0R302

Original issue reported on code.google.com by su...@surmair.de on 5 Dec 2012 at 9:06

Attachments:

GoogleCodeExporter commented 9 years ago
Seems like a reasonable approach. Can you please send a CL as per 
http://golang.org/doc/contribute.html ?

Original comment by a...@golang.org on 7 Dec 2012 at 3:40

GoogleCodeExporter commented 9 years ago
Is there a problem with just setting the Accept: header for json?  I made a 
transport that adds it before the Exchange and it works now with GitHub.

Original comment by kev...@google.com on 7 Dec 2012 at 9:58

GoogleCodeExporter commented 9 years ago
I found it easier to check the Content-Type then implementing a new Transport.
Also: How do you know that the provider actually supports json? This way, you 
definitely get an answer you just need to be able to decode it.

Original comment by su...@surmair.de on 7 Dec 2012 at 10:08

GoogleCodeExporter commented 9 years ago
Issue 4 has been merged into this issue.

Original comment by a...@golang.org on 11 Dec 2012 at 11:18

GoogleCodeExporter commented 9 years ago
This looks to have been fixed in 
https://code.google.com/p/goauth2/source/detail?r=f3b3146d6c91  I've manually 
verified that it works with both GitHub and Facebook.

Original comment by willnorris@google.com on 5 Jun 2013 at 4:27