OAuth2: query string vs. fragment
Just noticed that in OAuth2 when the requested grant type is: "code" the callback contains it in the query string parameters (after '?'). However, when the grant is "token" it is passed as a fragment (after '#').
This looks to be part of a spec (http://tools.ietf.org/html/draft-ietf-oauth-v2-26#section-4.2)
What could be a rationale behind such decision?
Thanks, Piotr
When your browser gets redirected by a website to a URL with a query parameter, the query string is also part of the request that your browser now sends to the host. Fragments are only evaluated locally by your web browser and not included into the request to the host.
In case of the Authorization Code Grant , where you typically have a web application, that directly talks to a provider, sending the data to the host is exactly what you need:
In case of the Implicit Grant , you typically have some Javascript application directly running in your browser. There's no need to pass any authorization code to the host and in most cases there's also no need to send the access token to the host, as the JS in the browser can directly talk to the provider. This way you could eg create a website on a server that uses information queried from another provider with consent from the user where the server never gets access to any confidential data of the user. (In case of a trusted website, that doesn't send the access token to the server.)
链接地址: http://www.djcxy.com/p/48008.html上一篇: 如何在Android上使用MAC访问验证签名标题?
下一篇: OAuth2:查询字符串与片段