user2149780
user2149780

Reputation: 175

Meteor OAuth Server error: Failed to complete OAuth handshake with Instagram

I'm using https://github.com/meteor-helium/instagram package to handle Instagram login.

In my server/social-config.js, I have

ServiceConfiguration.configurations.remove({
    service: 'instagram'
});
ServiceConfiguration.configurations.insert({
    service: 'instagram',
    clientId: '****',
    secret: '****'
});

In my client/main.html, I have

<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>

In my client/main.js, I have

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");
        }
    })
}
});

I get the following error when I click the "Sign in with Instagram" button

Error in OAuth Server: Failed to complete OAuth handshake with Instagram. failed [400] {"code": 400, "error_type": "OAuthException", "error_message": "Invalid Client Secret"}

Upvotes: 0

Views: 1313

Answers (2)

Ivan Cabrera
Ivan Cabrera

Reputation: 417

I got the same error but with 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

The client is a react native app, so, to solve it, make sure to use the same clientId in the server and in the mobile app.

Below is a picture where you can see different Client IDs, you need to choose Web Client option:

GCP platform -> API & Services -> Credentials

enter image description here

Also, make sure to add known domains for that client id record.

enter image description here

This allows to use OAuth Google either in localhost or in a server with domain.

Upvotes: 0

Alex K
Alex K

Reputation: 7217

I think that according to this https://github.com/meteor-helium/instagram/blob/master/instagram_configure.js#L10 The client secret property name should be clientSecret, not secret.

ServiceConfiguration.configurations.insert({
    service: 'instagram',
    clientId: '****',
    clientSecret: '****'
});

Upvotes: 1

Related Questions