Skip to content

Commit ba46461

Browse files
authored
Merge pull request #22 from mraible/add-okta-and-keycloak
Add Okta and Keycloak settings
2 parents bdf0085 + ceb4361 commit ba46461

File tree

1 file changed

+52
-1
lines changed

1 file changed

+52
-1
lines changed

README.md

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ This library _should_ support any OAuth provider that implements the
1414
* [Identity Server4](https://demo.identityserver.io/) ([Example configuration](#identity-server-4))
1515
* [Google](https://developers.google.com/identity/protocols/OAuth2)
1616
([Example configuration](#google))
17+
* [Okta](https://developer.okta.com) ([Example configuration](#okta))
18+
* [Keycloak](http://www.keycloak.org/) ([Example configuration](#keycloak))
1719

1820
The library uses auto-discovery which mean it relies on the the
1921
[.well-known/openid-configuration](https://openid.net/specs/openid-connect-discovery-1_0.html)
@@ -322,7 +324,7 @@ const sendClientIdOnRevoke = true;
322324
await appAuth.revokeToken(refreshedState.refreshToken, sendClientIdOnRevoke);
323325
```
324326

325-
## Google
327+
### Google
326328

327329
Full support out of the box.
328330

@@ -344,6 +346,55 @@ const refreshedState = appAuth.refresh(authState.refreshToken, scopes);
344346
await appAuth.revokeToken(refreshedState.refreshToken);
345347
```
346348

349+
### Okta
350+
351+
Full support out of the box.
352+
353+
> If you're using Okta and want to add App Auth to your React Native application, you'll need an application to authorize against. If you don't have an Okta Developer account, [you can signup for free](https://developer.okta.com/signup/).
354+
>
355+
> Log in to your Okta Developer account and navigate to **Applications** > **Add Application**. Click **Native** and click the **Next** button. Give the app a name you’ll remember (e.g., `React Native`), select `Refresh Token` as a grant type, in addition to the default `Authorization Code`. Copy the **Login redirect URI** (e.g., `com.oktapreview.dev-158606:/callback`) and save it somewhere. You'll need this value when configuring your app.
356+
>
357+
> Click **Done** and you'll see a client ID on the next screen. Copy the redirect URI and clientId values into your App Auth config.
358+
359+
```js
360+
const scopes = ["openid", "profile"];
361+
const appAuth = new AppAuth({
362+
issuer: 'https://{yourOktaDomain}.com/oauth2/default',
363+
clientId: '{clientId}',
364+
redirectUrl: 'com.{yourReversedOktaDomain}:/callback'
365+
});
366+
367+
// Log in to get an authentication token
368+
const authState = await appAuth.authorize(scopes);
369+
370+
// Refresh token
371+
const refreshedState = appAuth.refresh(authState.refreshToken, scopes);
372+
373+
// Revoke token
374+
await appAuth.revokeToken(refreshedState.refreshToken);
375+
```
376+
377+
### Keycloak
378+
379+
Keycloak [does not specify a revocation endpoint](http://keycloak-user.88327.x6.nabble.com/keycloak-user-Revoking-an-OAuth-Token-td3041.html) so revoke functionality doesn't work.
380+
381+
If you use [JHipster](http://www.jhipster.tech/)'s default Keycloak Docker image, everything will work with the following settings, except for revoke.
382+
383+
```js
384+
const scopes = ["openid", "profile"];
385+
const appAuth = new AppAuth({
386+
issuer: 'http://localhost:9080/auth/realms/jhipster',
387+
clientId: 'web_app',
388+
redirectUrl: '<YOUR_REDIRECT_SCHEME>:/callback'
389+
});
390+
391+
// Log in to get an authentication token
392+
const authState = await appAuth.authorize(scopes);
393+
394+
// Refresh token
395+
const refreshedState = appAuth.refresh(authState.refreshToken, scopes);
396+
```
397+
347398
## Contributors
348399

349400
Thanks goes to these wonderful people

0 commit comments

Comments
 (0)