OAuth2 code to front-end from back-end not working

Viewed 125

I've been trying to implement OAuth2 for Google Sign-in with Vue and Deno, these are the relevant endpoints / domains

Back-end: localhost:8182
Front-end: localhost:8080

This is the flow of my setup: on the Vue front-end I fetch an authorization URI from the back-end, I've created this authorization URI with http://localhost:8080 as a redirect URI. Once the user signs in I get directed back to the Vue front-end with the authorization code in the URL.

Now I want to turn my authorization code into an access token, so using JavaScript I fetch the code from the URL and forward it to the back-end verification endpoint http://localhost:8182/oauth/validate, but it returns this error:

Invalid authorization response: Redirect path should match configured path, but got: /oauth/validate

I figure that it errors out since I had the redirect URI set to http://localhost:8080 but I'm trying to get the token from /oauth/validate, I've also included my Google Cloud Console authorized URIs.

Google Cloud Console authorized URIs

How can I fix this? In another post I saw someone using the same logic (sending the code from the front-end to the back-end and awaiting the result). But I must be doing something wrong

1 Answers

Have you tried removing /oauth/validate? I have a similar case in my local application. Here is how the "Authorized redirect URIs" section looks like:

Authorized redirect URIs

Related