TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Jun 2015 |
Maintained by Hernan Zalazar.
Auth0 is an authentication broker that supports social identity providers as well as enterprise identity providers such as Active Directory, LDAP, Google Apps and Salesforce.
LockReact is a wrapper around Lock so it easier to use with React Native.
LockReact API is in Beta and might be subject to changes due to improvements in either Lock or React Native
iOS 7+ & React Native
In your project's Info.plist
file add the following entries:
You can find these values in your app's settings in Auth0 dashboard.
For example:
Also you need to register a Custom URL type, it must have a custom scheme with the following format a0<Your Client ID>
. For example if your Client ID is Exe6ccNagokLH7mBmzFejP
then the custom scheme should be a0Exe6ccNagokLH7mBmzFejP
.
Then you'll need to handle that custom scheme, so first import A0LockReact
header in your AppDelegate.m
#import <LockReact/A0LockReact.h>
and override -application:openURL:sourceApplication:annotation:
method, if you haven't done it before, and add the following line:
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
return [[[A0LockReact sharedInstance] lock] handleURL:url sourceApplication:sourceApplication];
}
This is required to be able to return back to your application when authenticating with Safari (or native integration with FB or Twitter if used). This call checks the URL and handles all that have the custom scheme defined before.
Finally in the file index.ios.js
, require Lock's module like this:
var Lock = require('NativeModules').LockReactModule;
Lock.init({});
Lock.show({}, (err, profile, token) => {
console.log('Logged in!');
});
And you'll see our native login screen
By default all social authentication will be done using Safari, if you want native integration please check this wiki page.
Lock.showTouchID({
authParams: {
connection: 'Username-Password-Authentication',
}
}, (err, profile, token) => {
console.log('Logged in!');
});
And you'll see TouchID login screen
Because it uses a Database connection, the user can change it's password and authenticate using email/password whenever needed. For example when you change your device.
Lock.showSMS({
apiToken: "API V2 TOKEN",
}, (err, profile, token) => {
console.log('Logged in!');
});
And you'll see SMS login screen
You need generate a v2 API Token used to register the phone number and send the login code with SMS. This token can be generated in Auth0 API v2 page, just select the scope
create:users
and copy the generated API Token.
Show Lock's authentication screen as a modal screen using the connections configured for your applications or the ones specified in the options
parameter. This is the list of valid options:
boolean
): If Lock screen can be dismissed[string]
): List of enabled connections to use for authentication. Must be enabled in your app's dashboard first.object
): Object with the parameters to be sent to the Authentication API, e.g. scope
.The callback will have the error if anything went wrong or after a successful authentication, it will yield the user's profile info and tokens.
Show Lock's SMS authentication screen as a modal screen. This is the list of valid options:
boolean
): If Lock screen can be dismissedobject
): Object with the parameters to be sent to the Authentication API, e.g. scope
.The callback will have the error if anything went wrong or after a successful authentication, it will yield the user's profile info and tokens.
Show Lock's TouchID authentication screen as a modal screen. This is the list of valid options:
boolean
): If Lock screen can be dismissedobject
): Object with the parameters to be sent to the Authentication API, e.g. scope
.The callback will have the error if anything went wrong or after a successful authentication, it will yield the user's profile info and tokens.
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 details the procedure for disclosing security issues.
Auth0 helps you to:
Auth0
LockReact is available under the MIT license. See the LICENSE file for more info.