Skip to content

New API

Compare
Choose a tag to compare
@kadikraman kadikraman released this 09 Feb 15:51
· 482 commits to main since this release

Improved API

Read all about it in the issue and relevant PR.

The main difference is that instead of instantiating an AppAuth class and having to keep track of it, you can now just use each of the methods: authorize, refresh and revoke directly, override their config when necessary and provide additional method-specific configuration.

Before

import AppAuth from 'react-native-app-auth';

const config = {
  issuer: '<YOUR_ISSUER_URL>',
  redirectUrl: '<YOUR_REDIRECT_URL>',
  clientId: '<YOUR_CLIENT_ID>'
};
const appAuth = new AppAuth(config);

// authorize
const scopes = '<YOUR_SCOPES_ARRAY>';
const result = await appAuth.authorize(scopes);

// refresh
const scopes = '<YOUR_SCOPES_ARRAY>';
const result = await appAuth.refresh(scopes);

// revoke
const tokenToRevoke = '<TOKEN_TO_REVOKE>';
const sendClientId = '<BOOLEAN>';
const result = await appAuth.revokeToken(tokenToRevoke, sendClientId = false);

After

import { authorize, refresh, revoke } from 'react-native-app-auth';

const config = {
  issuer: '<YOUR_ISSUER_URL>',
  redirectUrl: '<YOUR_REDIRECT_URL>',
  clientId: '<YOUR_CLIENT_ID>',
  scopes: '<YOUR_SCOPES_ARRAY>'
};

// authenticate
const result = await authorize(config);

// refresh
const result = await refresh(config, {
  refreshToken: result.refreshToken,
});

// revoke
const result = await revoke(config, {
  tokenToRevoke: result.accessToken,
  sendClientId: '<BOOLEAN>'
});

Bugfixes

  • Fixed Example App Release Build #20
  • Exposed missing parameters form token request #34

Enhancements

  • Added Okta and Keycloak instructions to the Readme #22
  • Enable passing additionalParameters to the auth request #33
  • Our amazing new Logo ❤️#39