2

我试图用 servicestack 创建一个 google oauthprovider,但我遇到了一些麻烦。(我在这里按照谷歌的描述使用 OAuth 2.0 for Web Server Applications

我从https://accounts.google.com/o/oauth2/auth得到(似乎是正确的)代码,但是当我尝试处理响应时(使用这个:)

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");

我收到了 400 错误请求。查看提琴手(将 url 修改为 http)我看到以下内容:

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

这似乎与文档中描述的内容很匹配,那么为什么会出现错误请求?

我真的被困在这里了。谢谢你的帮助!

拉尔西

4

0 回答 0