【发布时间】:2014-08-27 22:36:33
【问题描述】:
我正在使用 rails/ember 应用程序中的omniauth,并且在使用 google 登录时遇到了一些问题。我收到了弹出窗口以允许网站对我进行身份验证,但是在单击之后接受请求炸弹:
Uncaught SecurityError: Blocked a frame with origin "https://localhost:3001" from
accessing a frame with origin "https://accounts.google.com". Protocols, domains,
and ports must match.
我在本地开发中使用自签名证书获取 HTTPS,但如何在本地测试此身份验证逻辑?
Coffeescript 尝试登录:
$ ->
$.ajax
url: '//apis.google.com/js/client:plus.js?onload=gpAsyncInit'
dataType: 'script'
cache: true
window.gpAsyncInit = ->
$(".google-login").click (e) ->
e.preventDefault()
gapi.auth.authorize
immediate: false
response_type: "code"
client_id: "<%= ENV["GOOGLE_CLIENT_ID"] %>"
scope: "email profile"
, (response) ->
if response and not response.error
jQuery.ajax
type: "POST"
url: "/auth/google_oauth2/callback"
dataType: "json"
data: response
success: (json) ->
alert 'success!'
else
alert response.error
【问题讨论】:
标签: ruby-on-rails coffeescript oauth-2.0 google-oauth