onlyauth / sdk
OnlyAuth 2FA API PHP Library
v0.1.2
2024-02-29 16:52 UTC
Requires
- php: ^7.4 || ^8.0
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- guzzlehttp/guzzle: ^7.3
- guzzlehttp/psr7: ^1.7 || ^2.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.5
- phpunit/phpunit: ^8.0 || ^9.0
This package is not auto-updated.
Last update: 2024-04-26 15:48:28 UTC
README
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
Requirements
PHP 7.4 and later.
Composer
OnlyAuth SDK is available via Packagist, onlyauth/sdk. Install it via composter:
composer require onlyauth/sdk
Then run composer install
Manual Installation
Download the files and include autoload.php
:
<?php require_once('/path/to/OpenAPIClient-php/vendor/autoload.php');
Getting Started
Please follow the installation procedure and then run the following:
<?php require_once(__DIR__ . '/vendor/autoload.php'); // Configure Bearer (API Secret) authorization: BearerAuth $config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN'); $apiInstance = new OpenAPI\Client\Api\AuthenticationApi( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client(), $config ); $app_id = 'app_id_example'; // string | Uuid of the OnlyAuth App (APPX-XXX) $client_id = 'client_id_example'; // string | Uuid of you in the OnlyAuth Platform (CLNT-XXX) $end_user_phone_number = 'end_user_phone_number_example'; // string | Phone number of the end user (E164 format) $end_user_uuid = 'end_user_uuid_example'; // string | Uuid of the end user (any type) $redirect_uri = 'redirect_uri_example'; // string | URL to redirect to after authentication $language = 'language_example'; // string | Language code (e.g., en-US) $region = 'region_example'; // string | Region code (us-1) try { $result = $apiInstance->createAccessToken($app_id, $client_id, $end_user_phone_number, $end_user_uuid, $redirect_uri, $language, $region); print_r($result); } catch (Exception $e) { echo 'Exception when calling AuthenticationApi->createAccessToken: ', $e->getMessage(), PHP_EOL; }
API Endpoints
All URIs are relative to https://api.onlyauth.io
Class | Method | HTTP request | Description |
---|---|---|---|
AppsApi | deleteApp | DELETE /apps/{app_id} | Delete an app |
AppsApi | getAppById | GET /apps/{app_id} | Get an app by uuid |
AppsApi | getApps | GET /apps | Get all apps |
AppsApi | newApp | POST /apps | Create a new app |
AppsApi | updateApp | POST /apps/{app_id} | Update an app |
AuthenticationApi | createAccessToken | POST /server/access-tokens/new | Creates a short-lived JWT token to integrate the widget |
AuthenticationApi | validateSuccessToken | GET /server/success-tokens | Validates a success token after user completes authentication |
Models
- CreateAccessToken200Response
- DeleteApp200Response
- ErrorResponse
- GetApps200Response
- GetApps200ResponseAppsInner
- NewApp200Response
- ValidateSuccessToken200Response
Authorization
Authentication schemes defined for the API:
BearerAuth
- Type: Bearer authentication (API Secret)
Tests
To run the tests, use:
composer install vendor/bin/phpunit