Skip to content

Commit

Permalink
Allow redirect uri to be specified
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Krul authored and nkrul committed Feb 11, 2021
1 parent c923e69 commit 01bc57d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/lib/createAuthContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({})
Expand Down Expand Up @@ -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})
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/lib/helpers/authorize.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 01bc57d

Please sign in to comment.