Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add refresh token to instructions #1490

Merged
merged 4 commits into from
Mar 1, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions _source/_posts/2024-02-28-okta-authentication-angular.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ You'll use Okta to securely handle authentication and authorization for your Ang

Note the `Issuer` and the `Client ID`. You'll need those values for your authentication configuration coming up soon.

There's one manual change to make in the Okta Admin Console. You'll add the **Refresh Token** grant type to your Okta application. Open a browser tab to sign in to your [Okta developer account](https://developer.okta.com/login/). Navigate to **Applications** > **Applications** and find the Okta Application you created. For Okta Applications using the default name, find the Application named "My SPA", otherwise find the Application with your custom name. Select the name to edit the application. Find **General Settings** section and press the **Edit** button to add a Grant type. Activate the **Refresh Token** checkbox and press **Save**.

We'll use the [Okta Angular](https://www.npmjs.com/package/@okta/okta-angular) and [Okta Auth JS](https://www.npmjs.com/package/@okta/okta-auth-js) libraries to connect our Angular application with Okta authentication. Add them to your project by running the following command:

```shell
Expand All @@ -110,7 +112,8 @@ export const appConfig: ApplicationConfig = {
oktaAuth: new OktaAuth({
issuer: 'https://{yourOktaDomain}/oauth2/default',
clientId: '{yourClientId}',
redirectUri: `${window.location.origin}/login/callback`
redirectUri: `${window.location.origin}/login/callback`,
scopes: ['openid', 'offline_access', 'profile']
})
})
),
Expand Down Expand Up @@ -414,7 +417,13 @@ function configInitializer(httpBackend: HttpBackend, configService: OktaAuthConf
new HttpClient(httpBackend)
.get('api/config.json')
.pipe(
tap((authConfig: any) => configService.setConfig({oktaAuth: new OktaAuth({...authConfig, redirectUri: `${window.location.origin}/login/callback`})})),
tap((authConfig: any) => configService.setConfig({
oktaAuth: new OktaAuth({
...authConfig,
redirectUri: `${window.location.origin}/login/callback`,
scopes: ['openid', 'offline_access', 'profile']
})
})),
take(1)
);
}
Expand Down
Loading