-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
feat: oauth for chrome extension #4870
feat: oauth for chrome extension #4870
Conversation
TODOs/FIXMEs:
|
@@ -1,4 +1,8 @@ | |||
import Crypto from 'crypto-js'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot use node:crypto
to create a codeVerifier
and codeChallenge
since this project is outside of node scope, hence the different alternative crypto-js
// export const RenewToken = async (appToken: string): Promise<Tokens | null> => { | ||
// const data = await callQuery<Tokens>(RENEW_TOKEN, { appToken }); | ||
// if (isDefined(data)) return data; | ||
// else return null; | ||
// }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think its best to implement this in a follow up PR
{isAuthenticating ? ( | ||
<Loader /> | ||
) : ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the loader in here because we don't need a separate loading page now
@AdityaPimpalkar could you add a PR description here too, it will help the review :) |
|
||
host_permissions: ['https://www.linkedin.com/*'], | ||
host_permissions: ['https://www.linkedin.com/*', 'http://localhost:3001/*'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only add Localhost in dev env
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise add twenty.com (app or api?)
Previously we had to create a separate API key to give access to chrome extension so we can make calls to the DB. This PR includes logic to initiate a oauth flow with PKCE method which redirects to the `Authorise` screen to give access to server tokens. Implemented in this PR- 1. make `redirectUrl` a non-nullable parameter 2. Add `NODE_ENV` to environment variable service 3. new env variable `CHROME_EXTENSION_REDIRECT_URL` on server side 4. strict checks for redirectUrl 5. try catch blocks on utils db query methods 6. refactor Apollo Client to handle `unauthorized` condition 7. input field to enter server url (for self-hosting) 8. state to show user if its already connected 9. show error if oauth flow is cancelled by user Follow up PR - Renew token logic --------- Co-authored-by: Félix Malfait <[email protected]>
Previously we had to create a separate API key to give access to chrome extension so we can make calls to the DB. This PR includes logic to initiate a oauth flow with PKCE method which redirects to the
Authorise
screen to give access to server tokens.Implemented in this PR-
redirectUrl
a non-nullable parameterNODE_ENV
to environment variable serviceCHROME_EXTENSION_REDIRECT_URL
on server sideunauthorized
conditionFollow up PR -
Renew token logic