无法使用JavaScript中的Google日历(v3)API中的OAuth 2.0进行身份验证 [英] Cannot Authenticate using OAuth 2.0 in Google Calendar (v3) API in JavaScript

查看:127
本文介绍了无法使用JavaScript中的Google日历(v3)API中的OAuth 2.0进行身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试根据

I am attempting to create Google Calendar events as per the code given at here. I've narrowed the probem down to an authentication issue in the following call:

gapi.auth.authorize({client_id: clientId, scope: 'https://www.googleapis.com/auth/calendar', immediate: true}, handleAuthResult);

,它不返回访问令牌.返回的auth对象如下所示:

which does not return an access token. The returned auth object looks like this:

client_id: "xxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com", cookie_policy: undefinederror: "immediate_failed", error_subtype: "access_denied"expires_at: "1432593971"expires_in: "86400"g_user_cookie_policy: undefinedissued_at: "1432507571"response_type: "token"scope: "https://www.googleapis.com/auth/calendar"state: ""

我知道我的日历配置正确(即client_id),因为我可以提取事件并将其放入列表中

I know my calendar configuration is correct (i.e. client_id) because as I can pull events and place them into a list see example. This is because reading events doesn't require OAuth 2.0 - it only requires a public api key.

此外,我可以使用此程序以编程方式创建事件Java API 通过仅提供我的client_id.请注意底部附近的魔术按钮,该按钮可使用OAuth 2.0授权请求.启用此功能后,一切正常.那么问题是如何在JavaScript/浏览器环境中以编程方式完成此操作?

Furthermore, I am able to create events programatically using this Java API by supplying only my client_id. Notice the magic button near the bottom which offers to authorize requests using OAuth 2.0. When I enable this everything works fine. So the question is how is this done programatically in a JavaScript/browser environment?

推荐答案

我发现浏览器中的弹出窗口被阻止,这阻止了身份验证过程的完成.一旦启用弹出窗口,该过程便能够成功完成. h!该代码是完整的,毕竟还可以.

I had discovered that popups were blocked in my browser and this prevented the authentication process from completing. Once I enabled popups, the process was able to complete successfully. Doh! The code was complete and OK after all.

这篇关于无法使用JavaScript中的Google日历(v3)API中的OAuth 2.0进行身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆