Skip to content

Commit

Permalink
Update authentication token usage to access_token; modify OIDC scope …
Browse files Browse the repository at this point in the history
…for API permissions
  • Loading branch information
remyvdwereld committed Dec 16, 2024
1 parent 0f07b43 commit 2edb5f7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type Props = {
*/
const ProtectedRoute: React.FC<Props> = ({ page: Page, ...restProps }) => {
const auth = useAuth()
const token = auth.user?.id_token
const token = auth.user?.access_token

return token
? <Page { ...restProps } />
Expand Down
2 changes: 1 addition & 1 deletion src/app/state/auth/oidc/oidcConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const oidcConfig = {
client_id: `${ env.VITE_OIDC_CLIENT_ID }`,
redirect_uri: `${ env.VITE_OIDC_REDIRECT_URL }`,
response_type: "code",
scope: "openid email",
scope: `openid email api://${ env.VITE_OIDC_CLIENT_ID }/user_impersonation`,
post_logout_redirect_uri: `${ env.VITE_OIDC_REDIRECT_URL }`,
metadata: {
issuer: "https://login.microsoftonline.com/72fca1b1-2c2e-4376-a445-294d80196804/v2.0",
Expand Down
4 changes: 2 additions & 2 deletions src/app/state/rest/hooks/useProtectedRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const useProtectedRequest = () => {
const request = useRequest()

return useCallback(async (method: Method, url: string, data?: unknown, additionalHeaders = {}) => {
const token = auth.user?.id_token
const token = auth.user?.access_token
const headers = {
Authorization: `Bearer ${ token }`,
...additionalHeaders
Expand All @@ -21,7 +21,7 @@ const useProtectedRequest = () => {
headers
)
return response
}, [auth.user?.id_token, request])
}, [auth.user?.access_token, request])
}

export default useProtectedRequest

0 comments on commit 2edb5f7

Please sign in to comment.