SignIn callback error when using NextAuth with oauth_get_access_token_error and oauth_callback_error
See original GitHub issueI 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:
- Created 2 years ago
- Reactions:1
- Comments:19 (8 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@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-providerPlease 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.