fix: add environment variables for OAuth2 (#2216)

Co-authored-by: Arun Menon <arun.menon@autogeneral.com.au>
Co-authored-by: liyasthomas <liyascthomas@gmail.com>
This commit is contained in:
ntarunmenon
2022-04-04 16:07:18 +10:00
committed by GitHub
parent 4b46d2ce4a
commit dcbc3b6356
3 changed files with 36 additions and 42 deletions

View File

@@ -148,6 +148,7 @@ const tokenRequest = async ({
authUrl,
accessTokenUrl,
clientId,
clientSecret,
scope,
}) => {
// Check oauth configuration
@@ -160,10 +161,10 @@ const tokenRequest = async ({
// eslint-disable-next-line camelcase
accessTokenUrl = token_endpoint
}
// Store oauth information
setLocalConfig("tokenEndpoint", accessTokenUrl)
setLocalConfig("client_id", clientId)
setLocalConfig("client_secret", clientSecret)
// Create and store a random state value
const state = generateRandomString()
@@ -221,6 +222,7 @@ const oauthRedirect = () => {
grant_type: "authorization_code",
code: q.code,
client_id: getLocalConfig("client_id"),
client_secret: getLocalConfig("client_secret"),
redirect_uri: redirectUri,
code_verifier: getLocalConfig("pkce_codeVerifier"),
})
@@ -234,6 +236,7 @@ const oauthRedirect = () => {
removeLocalConfig("pkce_codeVerifier")
removeLocalConfig("tokenEndpoint")
removeLocalConfig("client_id")
removeLocalConfig("client_secret")
return tokenResponse
}
return Promise.reject(tokenResponse)