@capacitor-community/auth0
(WORK IN PROGRESS)
A native plugin for Auth0 authentication provider
Maintainer | GitHub | Social |
---|---|---|
Priyank Patel | priyankpat | @priyankpat_ |
Using npm:
npm install @capacitor-community/auth0
Using yarn:
yarn add @capacitor-community/auth0
Sync native files:
npx cap sync
On iOS, no further steps are needed.
On Android, make changes to the following files:
AndroidManifest.xml
:
Replace AUTH0_HOST with Tenant Domain provided by Auth0.
<activity ...>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="AUTH0_HOST"
android:pathPrefix="/android/${applicationId}/callback"
android:scheme="${applicationId}" />
</intent-filter>
</activity>
MainActivity.java
:
import com.getcapacitor.community.auth0.Auth0;
public class MainActivity extends BridgeActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Initializes the Bridge
this.init(
savedInstanceState,
new ArrayList<Class<? extends Plugin>>() {
{
// Additional plugins you've installed go here
// Ex: add(TotallyAwesomePlugin.class);
add(Auth0.class);
}
}
);
}
}
Name | Android | iOS | Web |
---|---|---|---|
authorize | ✅ | ✅ | ❌ |
clearSession | ✅ | ✅ | ❌ |
import Auth0 from '@capacitor-community/auth0';
/*
* Create a new instance of the client using the Auth0 domain and client id.
*/
const auth0 = new Auth0({
domain: 'DOMAIN',
clientId: 'CLIENT_ID',
});
/**
* Platform: Android/iOS
* This method trigger a auth0 web authentication.
* @params scope - list of scope seperated by whitespace
* @returns void
*/
auth0.webAuth
.authorize({ scope: 'openid email profile' })
.then(credentials => console.log(credentials))
.catch(error => console.log(error));
/**
* Platform: Android/iOS
* This method trigger a auth0 logout.
* @params scope - list of scope seperated by whitespace
* @returns void
*/
auth0.webAuth.clearSession().catch(error => console.log(error));
// Management API (Users) (Coming Soon)
// Authentication API (Coming Soon)