From 01bc57d806977d0f360ae7c0af56d5f3371156d7 Mon Sep 17 00:00:00 2001 From: Nick Krul Date: Thu, 14 Jan 2021 14:22:10 +1100 Subject: [PATCH] Allow redirect uri to be specified --- src/lib/createAuthContext.js | 5 +++-- src/lib/helpers/authorize.js | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/lib/createAuthContext.js b/src/lib/createAuthContext.js index bc33dc5..07b259d 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 }) => { 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..ad3bf5c 100644 --- a/src/lib/helpers/authorize.js +++ b/src/lib/helpers/authorize.js @@ -7,10 +7,11 @@ export default function authorize({ provider, clientId, scopes, - storage = sessionStorage + storage = sessionStorage, + redirect_uri }) { - const redirect_uri = window.location.toString() + redirect_uri = redirect_uri || window.location.toString() const encodedVerifier = base64URLEncode(createCodeVerifier()) storage.setItem(