Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/capacitor-community/auth0


https://github.com/capacitor-community/auth0

auth0 capacitor

Last synced: 24 days ago
JSON representation

Awesome Lists containing this project

README

        



Auth0


@capacitor-community/auth0


(WORK IN PROGRESS)



A native plugin for Auth0 authentication provider








## Maintainers

| Maintainer | GitHub | Social |
| ------------- | ------------------------------------------- | ------------------------------------------------ |
| Priyank Patel | [priyankpat](https://github.com/priyankpat) | [@priyankpat\_](https://twitter.com/priyankpat_) |

## Installation

Using npm:

```bash
npm install @capacitor-community/auth0
```

Using yarn:

```bash
yarn add @capacitor-community/auth0
```

Sync native files:

```bash
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.

```xml






```

`MainActivity.java`:

```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>() {

{
// Additional plugins you've installed go here
// Ex: add(TotallyAwesomePlugin.class);
add(Auth0.class);
}
}
);
}
}
```

## Supported methods

| Name | Android | iOS | Web |
| :------------------------------ | :------ | :-- | :-- |
| authorize | ✅ | ✅ | ❌ |
| clearSession | ✅ | ✅ | ❌ |

## Usage

```typescript
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)

```