Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The access token received from google oauth-providers/google is not valid JWT #468

Open
sabarivasanweb opened this issue Apr 21, 2024 · 3 comments

Comments

@sabarivasanweb
Copy link

I am pretty new to hono and oauth. I am using this straight forward googleauth implementation

import { Hono } from 'hono'
import { googleAuth } from '@hono/oauth-providers/google';

const app = new Hono();

app.get('/auth/google/sign-in',
  googleAuth({
    client_id: Bun.env.GOOGLE_ID,
    client_secret: Bun.env.GOOGLE_SECRET,
    scope: ['openid', 'email', 'profile'],
  }),
  (c) => {
    const token = c.get('token')
    const grantedScopes = c.get('granted-scopes')
    const user = c.get('user-google')

    return c.json({
      token,
      grantedScopes,
      user,
    })
  })

export default app

This is the sample token i am receiving

ya29.a0Ad52N39jfonKlkt81bjY8RntmIr-O9oD2uPhOkyC4zRniCgY49qbDkW3cZ-MEz6ZdraJQC1LHFtgQAka6fGRxyoV0YSCXZzSJmKWsR_qrjW3DlMTVTX9DsLYYLXO_ghRIMi2rJLmjU7Yqc3SMhXC84VBAPyO1vxRywaCgYKAXUSARASFQHGX2MioTv67Z0opiAWcEKQ89BINg0169

I am wondering if its a JWT or not. It supposed to be an access token but i cant verify it with my secret. I am receiving the user data correctly.
Is it a valid token? if not how can i get valid JWT token?

@JoaquimLey
Copy link

That token is used to talk with Google APIs and not your own server, it is not your JWT secret (you never pass it or should).

Depending on your use case, store the incoming data from Google (such as the user profile) on your database and then create a JWT using your secret with the desired payload/data you want to pass down to the client (eg: a Frontend application).

@sabarivasanweb
Copy link
Author

sabarivasanweb commented May 14, 2024

That token is used to talk with Google APIs and not your own server, it is not your JWT secret (you never pass it or should).

Depending on your use case, store the incoming data from Google (such as the user profile) on your database and then create a JWT using your secret with the desired payload/data you want to pass down to the client (eg: a Frontend application).

Is that it. Is it possible to get more details or a related documentation about the token received?

@JoaquimLey
Copy link

JoaquimLey commented May 14, 2024

Yes, if you do your own research you'll find all the details you need.

Search for "Google oAuth flow"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants