onlyauth
v0.1.2
Published
OnlyAuth 2FA API Javascript Library
Downloads
2
Maintainers
Readme
OnlyAuth Javascript Library
Sign up for OnlyAuth 2FA API
Sign up for the OnlyAuth 2FA API to get your API credentials.
Installation Guide
Check out the OnlyAuth 2FA API Implementation guide for full details.
SDK Installation
For Node.js
npm
Install it via:
npm install onlyauth --save
Finally, you need to build the module:
npm run build
git
Install it via:
npm install onlyauth-io/onlyauth-javascript
Webpack Configuration
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
}
}
]
}
Getting Started
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);
});
Documentation for API Endpoints
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
Documentation for Models
- Onlyauth.CreateAccessToken200Response
- Onlyauth.DeleteApp200Response
- Onlyauth.ErrorResponse
- Onlyauth.GetApps200Response
- Onlyauth.GetApps200ResponseAppsInner
- Onlyauth.NewApp200Response
- Onlyauth.ValidateSuccessToken200Response
Documentation for Authorization
Authentication schemes defined for the API:
BearerAuth
- Type: Bearer authentication (API Secret)