使用多个uris获取redirect_uri_mismatch错误

Jac*_*kie 3 curl oauth-2.0

我正在尝试使用Google Oauth v2.我进入我的api控制台并设置以下2重定向uris ...

http://localhost:3000/auth/authenticate
http://localhost:3000/auth/google/getToken
Run Code Online (Sandbox Code Playgroud)

当我运行以下...

curl -d "code=<removed>&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fauth%2Fgoogle%2fgetToken&client_id=<removed>&client_secret=<removed>&grant_type=authorization_code" -X POST https://accounts.google.com/o/oauth2/token
Run Code Online (Sandbox Code Playgroud)

然而,一切都很好

curl -d "code=<removed>&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fauth%2Fauthenticate&client_id=<removed>&client_secret=<removed>&grant_type=authorization_code" -X POST https://accounts.google.com/o/oauth2/token
Run Code Online (Sandbox Code Playgroud)

没说...

"error" : "redirect_uri_mismatch"
Run Code Online (Sandbox Code Playgroud)

我只是改变了这个,是否有传播时间框架?我如何让两个uris工作?

000*_*000 8

如上所述这里您发送REDIRECT_URI你把它用于验证的第二次(他们需要匹配),而这不是一个任意值.在请求访问令牌时,您需要为redirect_uri传递相同的值,其值为redirect_uri,您要求在授权后重定向用户.否则谷歌(或任何其他提供商将生成错误消息).