https://github.com/auth0/auth0-cordova
Auth0 integration for Cordova apps
https://github.com/auth0/auth0-cordova
cordova-plugin dx-sdk
Last synced: 3 days ago
JSON representation
Auth0 integration for Cordova apps
- Host: GitHub
- URL: https://github.com/auth0/auth0-cordova
- Owner: auth0
- License: mit
- Archived: true
- Created: 2014-08-12T21:15:10.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2023-10-27T13:52:34.000Z (almost 2 years ago)
- Last Synced: 2024-09-24T21:04:31.581Z (about 1 year ago)
- Topics: cordova-plugin, dx-sdk
- Language: JavaScript
- Homepage:
- Size: 22.3 MB
- Stars: 49
- Watchers: 68
- Forks: 66
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# Auth0 Cordova
[](https://app.fossa.com/projects/git%2Bgithub.com%2Fauth0%2Fauth0-cordova?ref=badge_shield)> **Warning**
> This library has been deprecated, and official support will end on October 31, 2023. See the [Migration Guide](./MIGRATION_GUIDE.md) for information to migrate your application to one of our other libraries.Library to make it easy to integrate Auth0 login in your Cordova applications.
## Requirements
The library requires these two cordova plugins to work:
- cordova-plugin-safariviewcontroller: Shows Safari/Chrome browser ViewController/CustomTab
- cordova-plugin-customurlscheme: Handles the custom scheme url intents for callbackyou'll need to run
```bash
cordova plugin add cordova-plugin-safariviewcontroller
cordova plugin add cordova-plugin-customurlscheme --variable URL_SCHEME={application package name} --variable ANDROID_SCHEME={application package name} --variable ANDROID_HOST={auth0 domain} --variable ANDROID_PATHPREFIX=/cordova/{application package name}/callback
```> In cordova applications, the application package name is the widget's identifier in `config.xml`
So if you have the following values
* application package name or widget identifier: com.auth0.cordova.example
* auth0 domain: samples.auth0.comin your config you should have some entries like
```xml
```
## Setup
From [npm](https://npmjs.org)
```sh
npm install @auth0/cordova
```then in your index.js you need to register the url handler `ondeviceready`
```js
var Auth0Cordova = require('@auth0/cordova');function main() {
function handlerUrl(url) {
Auth0Cordova.onRedirectUri(url);
}
window.handleOpenURL = handlerUrl;
// init your application
}document.addEventListener('deviceready', main);
```## Usage
```js
const auth0 = new Auth0Cordova({
domain: "{YOUR_AUTH0_DOMAIN}",
clientId: "{YOUR_AUTH0_CLIENT_ID}",
packageIdentifier: "{WIDGET_ID_IN_CONFIG_XML}"
});const options = {
scope: 'openid profile',
};auth0.authorize(options, function (err, result) {
if (err) {
// failure
}
// success!
});
```This will open your tenant's hosted login page in the OS browser and will use OAuth 2.0 code grant flow with [Proof Key for Code Exchange](https://tools.ietf.org/html/rfc7636).
## API
For more information about our API please check our [online documentation](https://auth0.github.io/auth0-cordova/)
## Issue Reporting
If you have found a bug or if you have a feature request, please report them at this repository issues section. Please do not report security vulnerabilities on the public GitHub issue tracker. The [Responsible Disclosure Program](https://auth0.com/whitehat) details the procedure for disclosing security issues.
For auth0 related questions/support please use the [Support Center](https://support.auth0.com).
## Common Issues
1. The plugin is not working in Ionic / Cordova dev app.
The plugin needs to be deployed on a real device to function, this is so because the dev apps do not add the necessary plugins needed for this library to function correctly. You'll need to either create a clone / fork of the Dev App or need to deploy it to a real device to test.
2. The app hangs after authentication
If 1 does not solve your problem, please make sure you have `cordova-plugin-customurlscheme` installed or an appropirate plugin to handle the callback (like deeplinks / universal links) and you are handling the callback appropriately
## Author
[Auth0](auth0.com)
## License
This project is licensed under the MIT license. See the [LICENSE](LICENSE.txt) file for more info.
[](https://app.fossa.com/projects/git%2Bgithub.com%2Fauth0%2Fauth0-cordova?ref=badge_large)