Releases: FormidableLabs/react-native-app-auth
Releases · FormidableLabs/react-native-app-auth
v2.1.0
Big thanks to @janpieterz, @PeterKottas, @jevakallio and @kitten for help on this release 🎉
New API
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>'
});