2

I was trying to create a google oauthprovider with servicestack but I'm having a bit trouble. (I'm following google's description here Using OAuth 2.0 for Web Server Applications

I'm getting (what seems to be a correct) code back from https://accounts.google.com/o/oauth2/auth but when I try handling the response (using this:)

var tmp = "client_id={0}&redirect_uri={1}&client_secret={2}&code={3}&grant_type=authorization_code".Fmt(this.ConsumerKey, this.CallbackUrl, this.ConsumerSecret, code);
var contents = "https://accounts.google.com/o/oauth2/token".PostToUrl(tmp, "application/x-www-form-urlencoded");

I get a 400 Bad Request back. Looking at fiddler (with url modified to http) I see the following:

POST http://accounts.google.com/o/oauth2/token HTTP/1.1
Accept: application/x-www-form-urlencoded
Host: accounts.google.com
Content-Length: 239
Expect: 100-continue

client_id=280348863874-ANDSOMEMOREDATase.apps.googleusercontent.com&
redirect_uri=http://localhost:49492/api/auth/google&
client_secret=NVHANDSOMEMOREDAT&
code=4/TWHupGxEXBQANDSOMEMOREDATA&
grant_type=authorization_code

This seems to match good with whats described in the docs, so why the Bad Request?

I'm really stuck here. Thanks for any help!

Larsi

Community
  • 1
  • 1
Larsi
  • 4,654
  • 7
  • 46
  • 75

0 Answers0