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

Chrome extension usage to handle token exchange #274

Open
yashomi-t3h opened this issue Sep 18, 2024 · 2 comments
Open

Chrome extension usage to handle token exchange #274

yashomi-t3h opened this issue Sep 18, 2024 · 2 comments

Comments

@yashomi-t3h
Copy link

yashomi-t3h commented Sep 18, 2024

I am planning to develop chrome extenstion where the user is required to sign in using google oauth. For extension to initiate flow it would call a method called chrome.identity.launchWebAuthFlow

From this call I am able to fetch code, access_token and id_token

https://.chromiumapp.org/#state=8v9lwh
&code= "code starting with 4 "
&access_token="starting with ya29"
&id_token="starting with ey"

I see in browser when doing oAuth you use the IDtoken and exchange it via API using following request to get the bearer token. However this gives me error for the token I recieved using chrome extention ( method chrome.identitylauchWebflow)

POST {{api-host}}/auth/exchange-code HTTP/1.1
Content-Type: application/json
Accept: application/json
Origin: http://localhost:3000
Referer: http://localhost:3000/

{
"code":
"<id_token>"
}

Error details are as below

Error: Invalid algorithm
   at Module.validateJWT (file:///Users/techex/experiments/gitquid/gitquid/app/node_modules/oslo/dist/jwt/index.js:55:15)
   at validateJWT (/Users/techex/experiments/gitquid/gitquid/app/.wasp/out/sdk/wasp/auth/jwt.ts:17:33)
   at Object.verifyToken (/Users/techex/experiments/gitquid/gitquid/app/.wasp/out/sdk/wasp/server/auth/oauth/oneTimeCode.ts:23:12)
   at <anonymous> (/Users/techex/experiments/gitquid/gitquid/app/.wasp/out/server/src/auth/providers/oauth/oneTimeCode.ts:23:47)
   at <anonymous> (/Users/techex/experiments/gitquid/gitquid/app/.wasp/out/sdk/wasp/server/utils.ts:26:11)
   at Layer.handle [as handle_request] (/Users/techex/experiments/gitquid/gitquid/app/.wasp/out/server/node_modules/express/lib/router/layer.js:95:5)
   at next (/Users/techex/experiments/gitquid/gitquid/app/.wasp/out/server/node_modules/express/lib/router/route.js:149:13)
   at Route.dispatch (/Users/techex/experiments/gitquid/gitquid/app/.wasp/out/server/node_modules/express/lib/router/route.js:119:3)
   at Layer.handle [as handle_request] (/Users/techex/experiments/gitquid/gitquid/app/.wasp/out/server/node_modules/express/lib/router/layer.js:95:5)
   at /Users/techex/experiments/gitquid/gitquid/app/.wasp/out/server/node_modules/express/lib/router/index.js:284:15

Not able to understand where it is going wrong?

@yashomi-t3h
Copy link
Author

Seems the wasp-lang only supports HMAC algorithm. Google oauth returns only RSA based Id_tokens. Is there any way to get around this when using chrome extension?

@infomiho
Copy link
Collaborator

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