Meteor OAuth 服务器错误:无法完成与 Instagram 的 OAuth 握手
Posted
技术标签:
【中文标题】Meteor OAuth 服务器错误:无法完成与 Instagram 的 OAuth 握手【英文标题】:Meteor OAuth Server error: Failed to complete OAuth handshake with Instagram 【发布时间】:2016-09-08 01:56:02 【问题描述】:我正在使用https://github.com/meteor-helium/instagram 包来处理 Instagram 登录。
在我的 server/social-config.js 中,我有
ServiceConfiguration.configurations.remove(
service: 'instagram'
);
ServiceConfiguration.configurations.insert(
service: 'instagram',
clientId: '****',
secret: '****'
);
在我的 client/main.html 中,我有
<template name="login">
#if currentUser
<button id="logout">Logout</button>
else
<button id="instagram-login" class="btn btn-default"> Login with Instagram</button>
/if
</template>
在我的 client/main.js 中,我有
Template.login.events(
'click #instagram-login': function(event)
Meteor.loginWithInstagram(, function(err)
if (err)
throw new Meteor.Error("Instagram login failed");
);
,
'click #logout': function(event)
Meteor.logout(function(err)
if (err)
throw new Meteor.Error("Logout failed");
)
);
单击“使用 Instagram 登录”按钮时出现以下错误
Error in OAuth Server: Failed to complete OAuth handshake with Instagram. failed [400] "code": 400, "error_type": "OAuthException", "error_message": "Invalid Client Secret"
【问题讨论】:
【参考方案1】:我认为根据这个https://github.com/meteor-helium/instagram/blob/master/instagram_configure.js#L10
客户端机密属性名称应为 clientSecret
,而不是 secret
。
ServiceConfiguration.configurations.insert(
service: 'instagram',
clientId: '****',
clientSecret: '****'
);
【讨论】:
【参考方案2】:我遇到了同样的错误,但使用 Google:
app | 2021-09-02T22:36:53.966810914Z Exception while invoking method 'login' Error: Failed to complete OAuth handshake with Google. failed [401] "error": "unauthorized_client", "error_description": "Unauthorized"
app | 2021-09-02T22:36:53.966854103Z at getTokens (packages/google-oauth/google_server.js:105:7)
app | 2021-09-02T22:36:53.966858709Z at MethodInvocation.<anonymous> (packages/google-oauth/google_server.js:63:27)
app | 2021-09-02T22:36:53.966863213Z at packages/accounts-base/accounts_server.js:512:31
app | 2021-09-02T22:36:53.966880535Z at tryLoginMethod (packages/accounts-base/accounts_server.js:1305:14)
app | 2021-09-02T22:36:53.966885506Z at AccountsServer._runLoginHandlers (packages/accounts-base/accounts_server.js:510:22)
app | 2021-09-02T22:36:53.966889786Z at MethodInvocation.methods.login (packages/accounts-base/accounts_server.js:570:31)
app | 2021-09-02T22:36:53.966893775Z at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1803:12)
app | 2021-09-02T22:36:53.966897605Z at packages/ddp-server/livedata_server.js:727:19
app | 2021-09-02T22:36:53.966901725Z at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1234:12)
app | 2021-09-02T22:36:53.966905836Z at packages/ddp-server/livedata_server.js:725:46
app | 2021-09-02T22:36:53.966909853Z at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1234:12)
app | 2021-09-02T22:36:53.966913596Z at packages/ddp-server/livedata_server.js:723:46
app | 2021-09-02T22:36:53.966917555Z at new Promise (<anonymous>)
app | 2021-09-02T22:36:53.966922191Z at Session.method (packages/ddp-server/livedata_server.js:697:23)
app | 2021-09-02T22:36:53.966927541Z at packages/ddp-server/livedata_server.js:561:43
客户端是一个 React Native 应用,因此,要解决它,请确保在服务器和移动应用中使用相同的 clientId。
下图是可以看到不同Client ID的图片,需要选择Web Client选项:
GCP 平台 -> API 和服务 -> 凭证
另外,请确保为该客户端 ID 记录添加已知域。
这允许在本地主机或具有域的服务器中使用 OAuth Google。
【讨论】:
以上是关于Meteor OAuth 服务器错误:无法完成与 Instagram 的 OAuth 握手的主要内容,如果未能解决你的问题,请参考以下文章
如何在没有手动浏览器身份验证的情况下从 Meteor.js 应用程序对 GMail-api 进行 oauth (2) 身份验证?