【问题标题】:How to use Google’s postmessage redirect uri scheme?如何使用 Google 的 postmessage redirect uri scheme?
【发布时间】:2017-06-17 23:22:07
【问题描述】:

一些像api exploer这样的谷歌网站使用mixed scheme而不是重定向到一个URI,在这个URI中,postmessage事件是由来自opener window的回调函数触发的,该回调函数由opener window接收(所以window.location.originwindow.origin 不同,但我不明白如何)

我找不到有关它的文档,但也许我搜索不正确。
主要优势似乎不需要服务器端令牌注册,因为一切都通过 JavaScript 发生。

Here’s <a href='javascript:window.open("https://accounts.google.com/o/oauth2/auth?client_id=292824132082.apps.googleusercontent.com&immediate=false&scope=https://www.googleapis.com/auth/userinfo.email&include_granted_scopes=false&proxy=oauth2relay604084667&redirect_uri=postmessage&origin=https://apis-explorer.appspot.com&response_type=token&gsiwebsdk=1&state=657454173|0.195379257&authuser=0&jsh=m;/_/scs/apps-static/_/js/k");'>an example script link</a> that will trigger a Domexception if not opened from https://apis-explorer.appspot.com/

此外,http://accounts.google.com/o/oauth2/auth 访问 window.opener 子元素,如果 window.opener.origin 匹配原点参数 在 url 中给出,因此绕过了 sop (但我不明白为什么没有使用 Acess-control-Allow-* 标头)。否则会触发异常。

那么使用 postmessage 执行 oauth2 身份验证的 JavaScript api 是什么? proxy= url 参数的作用是什么?

【问题讨论】:

    标签: javascript authentication google-signin google-oauth


    【解决方案1】:

    两种选择:

    1. 您可以使用 Google sign-in api for javascript 来请求额外的范围。见reference docs

    2. 你可以使用OAuth2 for javascript

    【讨论】:

    • 很好,但我知道。如何在不受服务器限制的情况下使用这些 api 进行身份验证。
    • 如果你解释你想要做什么可能会更容易。您遇到的服务器限制是什么?
    • 我试图了解这种机制是如何工作的。所以我需要复现它,因为学习 api explorer 已经不够了。
    • 但这不是我描述restfull而不是基于rpc的方式。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-17
    • 2011-03-16
    相关资源
    最近更新 更多