diff --git a/src/App.js b/src/App.js index 3d80c76..46753a7 100644 --- a/src/App.js +++ b/src/App.js @@ -10,6 +10,7 @@ const {AuthContext, Authenticated, useToken} = createAuthContext({ clientSecret, provider, // tokenEndpoint: 'http://localhost:3020/token' // If token endpoint is not "provider + '/token'" + // redirect_uri: "http://localhost:3001/" // If your redirect_uri is not just back to the current page }) function ProtectedStuff() { diff --git a/src/lib/createAuthContext.js b/src/lib/createAuthContext.js index bc33dc5..ab6df30 100644 --- a/src/lib/createAuthContext.js +++ b/src/lib/createAuthContext.js @@ -14,7 +14,8 @@ export default ({ tokenEndpoint = `${provider}/token`, storage = sessionStorage, fetch = window.fetch, - busyIndicator = <>logging in... + busyIndicator = <>logging in..., + redirect_uri = window.location.toString() }) => { const context = createContext({}) @@ -76,7 +77,7 @@ export default ({ const ensureAuthenticated = () => { const code = getCodeFromLocation({ location: window.location }) if (!token && !code) { - authorize({provider, clientId, scopes}) + authorize({provider, clientId, scopes, redirect_uri}) } } diff --git a/src/lib/helpers/authorize.js b/src/lib/helpers/authorize.js index fb48fd3..d6c4839 100644 --- a/src/lib/helpers/authorize.js +++ b/src/lib/helpers/authorize.js @@ -7,11 +7,10 @@ export default function authorize({ provider, clientId, scopes, - storage = sessionStorage + storage = sessionStorage, + redirect_uri }) { - const redirect_uri = window.location.toString() - const encodedVerifier = base64URLEncode(createCodeVerifier()) storage.setItem( getEncodedVerifierKey(clientId),