I have implemented custom Auth Resolver with okta where signIn works fine and i'm able to login in successfully. However on reloading the page, i'm getting kicked out of the site and lands on SignIn Page instead. The browser tries to make API call to
GET http://localhost:7007/api/auth/okta/refresh?optional=&scope=openid email profile offline_access&env=development
and it replies 401 unauthenticated with following error name: "AuthenticationError", message: "Refresh failed; caused by InputError: Missing session cookie.
I checked the request header / cookie are not being passes along.
Is it something wrong with me configuration ?
auth:
environment: development
providers:
okta:
development:
clientId: ${AUTH_OKTA_CLIENT_ID}
clientSecret: ${AUTH_OKTA_CLIENT_SECRET}
audience: ${AUTH_OKTA_DOMAIN}
backend.add(import('@backstage/plugin-auth-backend'));
backend.add(import('@backstage/plugin-auth-backend-module-guest-provider'));
backend.add(customAuthResolver);
components: {
SignInPage: props => {
return (
<SignInPage
{...props}
auto
provider={{
id: 'custom-auth-resolver',
title: 'Okta',
message: 'Sign in using Okta',
apiRef: oktaAuthApiRef,
}}
onSignInSuccess={async (identityApi: IdentityApi) => {
props.onSignInSuccess(identityApi);
}}
/>
);
},
},
The issue was with okta application configuration.
Be sure to specify refresh_token as a data_type value for the grant_type parameter when adding an OAuth client app (opens new window) using the /apps API.
https://developer.okta.com/docs/guides/refresh-tokens/main/
https://backstage.io/docs/auth/okta/provider
Make sure to select refresh_token in okta application configuration.