Hen*_*nry 8 redirect state mismatch oauth-2.0
根据Google Oauth 2.0文档的状态参数:
表示在收到响应后可能对您的应用程序有用的任何状态.Google授权服务器会将此参数往返,因此您的应用会收到与其发送的值相同的值.可能的用途包括将用户重定向到站点中的正确资源,nonce和跨站点请求伪造缓解.
我想使用state参数作为一种手段来了解原始oauth请求从哪个子域发起.但是redirect_state参数似乎需要注册为"授权重定向URI"之一.如果没有,我得到:
错误:redirect_uri_mismatch请求中的重定向URI:http://my_server.com/complete/google-oauth2/? redirect_state = 2与注册的重定向URI不匹配
我想要一个解决方案,不需要在授权的重定向URI中注册每个可能的redirect_state值,因为它不是很容易维护.想法?
div*_*shm 15
参数的名称是state(而不是redirect_state)!
根据Google文档的示例OAuth请求是 - >
https://accounts.google.com/o/oauth2/auth?
scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile&
state=%2Fprofile&
redirect_uri=https%3A%2F%2Foauth2-login-demo.appspot.com%2Fcode&
response_type=code&
client_id=812741506391.apps.googleusercontent.com&approval_prompt=force
Run Code Online (Sandbox Code Playgroud)
请注意State参数和redirect_uri参数.我认为你把两者混为一谈.
编辑 - 由Google 查看此链接.对状态参数和构建Web请求有很好的解释.
| 归档时间: |
|
| 查看次数: |
14915 次 |
| 最近记录: |