Can't Use/Debug Google OAuth from Xano

Options
Jeremie
Jeremie Member
edited July 2023 in ? Working with APIs

Hi! Would love your help solving this pickle. I'm building an app on Wized, and I'm trying to debug the Google OAuth flow directly in Xano so I can see full responses and tokens.

No matter what I do, I can't seem to get a valid response from google (invalid_grand, malformed auth code), see my steps below.

What am I missing? Going nuts after so many hours trying to figure this out.

Thanks!

Step 1: Add Xano to authorized URI and Redirect URI in Google Console

Step 2: Get auth URL in Xano

Step 3: Use the auth URL to get OAuth Code

I paste the auth URL from step 2 in a new tab, and I copy the oauth code from the url parameters

Step 4: Submit oauth token request - INVALID_GRANT

I use the oauth code from step 3 as input, and I am confident that this code hasn't been used yet to get a token (I took no other actions between step 3 and step 4)

(note: I know the code in the screenshot doesn't match, I tried multiple times)

{"request":{"url":"https://oauth2.googleapis.com/token","method":"POST","headers":["POST /token HTTP/2","Host: oauth2.googleapis.com","accept-encoding: gzip, deflate","content-type: application/x-www-form-urlencoded","accept: application/json","content-length: 300"],"params":{"code":"%2F0AZEOvhUH1pPSYleB_ZMu4EW-RcnE6yQdAz3WLIYUkBCreRgkyJ38UTMH_cQimPVYeIJWZg","client_id":"292126823835-m73boh7j58f78lb1rtq316e1o16l4i49.apps.googleusercontent.com","client_secret":"xxxxxx,"redirect_uri":"https://x8ki-letl-twmt.n7.xano.io/","grant_type":"authorization_code"}},"response":{"headers":["HTTP/2 400","pragma: no-cache","cache-control: no-cache, no-store, max-age=0, must-revalidate","expires: Mon, 01 Jan 1990 00:00:00 GMT","date: Mon, 03 Jul 2023 19:56:29 GMT","content-type: application/json; charset=utf-8","vary: Origin","vary: X-Origin","vary: Referer","content-encoding: gzip","server: scaffolding on HTTPServer2","content-length: 88","x-xss-protection: 0","x-frame-options: SAMEORIGIN","x-content-type-options: nosniff"],"result":{"error":"invalid_grant","error_description":"Malformed auth code."},"status":400}}

Tagged:

Comments

  • Jeremie
    Jeremie Member
    Options

    Solved - I had to decode the Auth URL to get a properly formatted OAUTH code.
    tldr copy paste the URL with the oauth code to here and decode https://meyerweb.com/eric/tools/dencoder/

  • Liz Anaya
    Liz Anaya Member, Administrator

    ADMIN

    Options

    Hi @Jeremie! 👋

    Thank you for sharing the solution! 🙏 It's super helpful in case other members face the same issue.