question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SignIn callback error when using NextAuth with oauth_get_access_token_error and oauth_callback_error

See original GitHub issue

I am trying to add custom oauth provider to my next.js app. I am adding custom provider in […nextauth].js:

export default NextAuth({
  // Configure one or more authentication providers
  providers: [
  {
    id: "moneybutton",
    name: "Money Button",
    type: "oauth",
    version: "2.0",
    scope: "auth.user_identity:read users.profiles:read users.profiles.email:read users.balance:read",
    params: {
      grant_type: "authorization_code"
    },
    accessTokenUrl: "https://www.moneybutton.com/oauth/v1/token",
    requestTokenUrl: "https://www.moneybutton.com/oauth/v1/token",
    authorizationUrl: "https://www.moneybutton.com/oauth/v1/authorize?response_type=code",
    profileUrl: "https://www.moneybutton.com/api/v1/auth/user_identity",

    profile(profile) {
      return {
        id: profile.data.attributes.id,
        name: profile.data.attributes.name,
      };
    },
    clientId: 'my_oauth_identifier',
    clientSecret: 'my_client_secret'
  }
    // ...add more providers here
  ],

  debug: true
});

OAuth flow seems to work correct, as i am seeing my profile id coming back in responses but it finishes on http://localhost:3000/api/auth/signin?error=Callback

I set debug to true and i am getting following errors:

[next-auth][error][oauth_get_access_token_error]
https://next-auth.js.org/errors#oauth_get_access_token_error {
  statusCode: 400,
  data: '{"errors":[{"id":"6da534f0-a512-11eb-92e8-891975d02f44","status":400,"title":"Bad Request","detail":"Invalid client: client is invalid"}],"jsonapi":{"version":"1.0"}}'
} undefined undefined
[next-auth][error][oauth_get_access_token_error]
https://next-auth.js.org/errors#oauth_get_access_token_error {
  statusCode: 400,
  data: '{"errors":[{"id":"6da534f0-a512-11eb-92e8-891975d02f44","status":400,"title":"Bad Request","detail":"Invalid client: client is invalid"}],"jsonapi":{"version":"1.0"}}'
} moneybutton 9f3970b8ae39f9d46f9fae56f6fb6135ecb7e87b
[next-auth][error][oauth_callback_error]
https://next-auth.js.org/errors#oauth_callback_error {
  statusCode: 400,
  data: '{"errors":[{"id":"6da534f0-a512-11eb-92e8-891975d02f44","status":400,"title":"Bad Request","detail":"Invalid client: client is invalid"}],"jsonapi":{"version":"1.0"}}'

It says that client is invalid, but i am sure oauth identifier and secret are correct, as well as redirect URL set to

http://localhost:3000/api/auth/callback/moneybutton

response for profile looks like this if it would be helpful:

{
    "data": {
        "id": "75101",
        "type": "user_identities",
        "attributes": {
            "id": "75101",
            "name": "John Doe"
        }
    },
    "jsonapi": {
        "version": "1.0"
    }
}

Links to documentations:

https://next-auth.js.org/configuration/providers https://docs.moneybutton.com/docs/api/v1/api-v1-user-identity I don’t know if it’s some bug or my approach is wrong and will apreciate any help

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:19 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
ndom91commented, Sep 5, 2021

@buccalon @michalscislowski we’ve just released a first beta of our next major version, NextAuth v4. Could you let us know if the issue still persists there? We’re using a more modern oauth library under the hood that supports stuff like the .well-known auto configuration stuff. Custom OAuth provider docs remain here: https://next-auth.js.org/configuration/providers/oauth-provider#using-a-custom-provider

0reactions
balazsorban44commented, Oct 27, 2021

Please provide a reproduction if you want help. I cannot verify that this is related to the OP’s issue, so I would recommend opening a new discussion/question.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Errors - NextAuth.js
Signin / Callback​. SIGNIN_OAUTH_ERROR​. This error occurs during the redirection to the authorization URL of the OAuth provider.
Read more >
oauth 2.0 - SignIn callback error when using NextAuth with ...
I am trying to add custom oauth provider to my next.js app. I am adding custom provider in [...nextauth].js : export default NextAuth({ ......
Read more >
next auth oauth callback error - You.com | The AI Search ...
Usually, this message means that you're missing the right redirect URI. In Azure, open your app registration, go to Authentication and enter the...
Read more >
Google oauth2.0 callback uri errors : r/reactjs - Reddit
I am using `next-auth` in a very VERY simple nextjs app, ... redirected to `https://baseurl.com/api/auth/signin?error=OAuthCallback` and on ...
Read more >
Callback url not working in Next js SDK - Auth0 Community
Below screen show after successfully login. Auth0 Configuration of callbackurl. Auth0 LOG: { “date”: “2022-03-30T11:19:28.134Z”, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found