OnlyAuth 2FA API PHP 库

v0.1.2 2024-02-29 16:52 UTC

This package is not auto-updated.

Last update: 2024-09-27 17:48:20 UTC


README

注册 OnlyAuth 2FA API

注册 OnlyAuth 2FA API 获取您的 API 凭据。

安装指南

查看 OnlyAuth 2FA API 实施指南 以获取详细信息。

SDK 安装

要求

PHP 7.4 及更高版本。

Composer

OnlyAuth SDK 通过 Packagist 提供,地址为 onlyauth/sdk。您可以通过 Composer 安装它

composer require onlyauth/sdk

然后运行 composer install

手动安装

下载文件并包含 autoload.php

<?php
require_once('/path/to/OpenAPIClient-php/vendor/autoload.php');

入门

请按照 安装程序 操作,然后运行以下命令

<?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 端点

所有 URI 都相对于 https://api.onlyauth.io

模型

授权

API 定义的认证方案

BearerAuth

  • 类型:Bearer 认证(API 密钥)

测试

要运行测试,请使用

composer install
vendor/bin/phpunit