Sign up for the OnlyAuth 2FA API to get your API credentials.
Check out the OnlyAuth 2FA API Implementation guide for full details.
For Node.js
Install it via:
npm install onlyauth --save
Finally, you need to build the module:
npm run build
Install it via:
npm install onlyauth-io/onlyauth-javascript
Using Webpack you may encounter the following error: "Module not found: Error: Cannot resolve module", most certainly you should disable AMD loader. Add/merge the following section to your webpack config:
module: {
rules: [
{
parser: {
amd: false
}
}
]
}
Please follow the installation instruction and execute the following JS code:
import onlyauth from 'onlyauth';
let defaultClient = onlyauth.ApiClient.instance;
// Configure Bearer (API Secret) access token for authorization: BearerAuth
let BearerAuth = defaultClient.authentications['BearerAuth'];
BearerAuth.accessToken = "API SECRET"
let apiInstance = new onlyauth.AuthenticationApi();
let appId = "appId_example"; // String | Uuid of the OnlyAuth App (APPX-XXX)
let clientId = "clientId_example"; // String | Uuid of you in the OnlyAuth Platform (CLNT-XXX)
let endUserPhoneNumber = "endUserPhoneNumber_example"; // String | Phone number of the end user (E164 format)
let endUserUuid = "endUserUuid_example"; // String | Uuid of the end user (any type)
let redirectUri = "redirectUri_example"; // String | URL to redirect to after authentication
let language = "language_example"; // String | Language code (e.g., en-US)
let region = "region_example"; // String | Region code (us-1)
apiInstance.createAccessToken(appId, clientId, endUserPhoneNumber, endUserUuid, redirectUri, language, region).then((data) => {
console.log('API called successfully. Token: ' + data.token);
}, (error) => {
console.error(error);
});
All URIs are relative to https://api.onlyauth.io
Class | Method | HTTP request | Description |
---|---|---|---|
OnlyAuth.AppsApi | deleteApp | DELETE /apps/{app_id} | Delete an app |
OnlyAuth.AppsApi | getAppById | GET /apps/{app_id} | Get an app by uuid |
OnlyAuth.AppsApi | getApps | GET /apps | Get all apps |
OnlyAuth.AppsApi | newApp | POST /apps | Create a new app |
OnlyAuth.AppsApi | updateApp | POST /apps/{app_id} | Update an app |
OnlyAuth.AuthenticationApi | createAccessToken | POST /server/access-tokens/new | Creates a short-lived JWT token to integrate the widget |
OnlyAuth.AuthenticationApi | validateSuccessToken | GET /server/success-tokens | Validates a success token after user completes authentication |
- Onlyauth.CreateAccessToken200Response
- Onlyauth.DeleteApp200Response
- Onlyauth.ErrorResponse
- Onlyauth.GetApps200Response
- Onlyauth.GetApps200ResponseAppsInner
- Onlyauth.NewApp200Response
- Onlyauth.ValidateSuccessToken200Response
Authentication schemes defined for the API:
- Type: Bearer authentication (API Secret)