Created
January 1, 2021 20:09
-
-
Save dcaponi/4550493eb0911283d250ff152437db19 to your computer and use it in GitHub Desktop.
second step in pkce flow to get an access token from our auth code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const PKCEAuthCodeSecondStep = ( code ) => { | |
let oidcURL = `${process.env.OIDC_IDP_URL}/token`; | |
let params = qs.stringify( { | |
grant_type: "authorization_code", | |
redirect_uri: "http://localhost/login_oidc", | |
client_id: process.env.OIDC_CLIENT_ID, | |
code_verifier: localStorage.getItem( 'code_verifier' ), | |
code | |
} ); | |
localStorage.removeItem( 'code_verifier' ); | |
return axios.post( oidcURL, params, | |
{ headers: { 'Content-Type': 'application/x-www-form-urlencoded' } } | |
).then( res => { | |
localStorage.setItem( 'access_token', res.data.access_token ); | |
return res.data | |
} ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment