You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am encountering an OAuth state mismatch error when implementing Google OAuth authentication using AdonisJS and the @adonisjs/ally package. Here’s a detailed breakdown of my implementation and the issue:
After a successful redirection to my client app, I pass the code and state (status) back to the backend using the /auth/google/handleCallback route. However, I receive the following error in my client:
However i get this error only in the hosted CLIENT and API. It works fine on my localhost.
Steps Taken:
In my Google Cloud Console, the redirect URL is set to https://clientUrl/loading.
In the client, I capture both code and state and pass them in the query parameters to the backend callback route.
I'm using AdonisJS with @adonisjs/ally version 5.0.2.
Expected Behavior:
Google should redirect back with a valid state that matches what the AdonisJS ally package expects, and I should be able to exchange the authorization code for a token successfully.
Request for Help:
I’m looking for guidance on how to properly handle the state parameter to avoid this "E_OAUTH_STATE_MISMATCH" error in AdonisJS with Google OAuth. Any insight or potential fixes would be greatly appreciated!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am encountering an OAuth state mismatch error when implementing Google OAuth authentication using
AdonisJS
and the@adonisjs/ally
package. Here’s a detailed breakdown of my implementation and the issue:Server-Side Code (authController.ts):
Route Setup:
Client-Side Code:
In the client, after Google redirects the user back, the code and state (status) parameters are captured, and the API request is made as follows:
Issue:
After a successful redirection to my client app, I pass the code and state (status) back to the backend using the /auth/google/handleCallback route. However, I receive the following error in my client:
However i get this error only in the hosted CLIENT and API. It works fine on my localhost.
Steps Taken:
In my Google Cloud Console, the redirect URL is set to https://clientUrl/loading.
In the client, I capture both code and state and pass them in the query parameters to the backend callback route.
I'm using AdonisJS with
@adonisjs/ally version 5.0.2
.Expected Behavior:
Google should redirect back with a valid state that matches what the AdonisJS ally package expects, and I should be able to exchange the authorization code for a token successfully.
Request for Help:
I’m looking for guidance on how to properly handle the state parameter to avoid this "E_OAUTH_STATE_MISMATCH" error in AdonisJS with Google OAuth. Any insight or potential fixes would be greatly appreciated!
Thanks in advance for any help or advice!
Beta Was this translation helpful? Give feedback.
All reactions