siddharthbhansali / dev-authkit-php

1.2.0 2024-07-09 03:17 UTC

This package is not auto-updated.

Last update: 2024-10-02 02:29:50 UTC


README

使用 IntegrationOS AuthKitComposer 生成安全令牌。

安装

使用 composer

composer require integration-os/authkit-php 

创建令牌端点

您需要创建一个内部端点,用于为前端生成安全令牌。您可以添加以下代码片段。然后,您可以直接在浏览器中调用该文件,或使用 curl 或 Postman 等工具通过向 http://yourserver.com/endpoint.php 发送 POST 请求。

<?php  // file endpoint.php

require "vendor/autoload.php";

use IntegrationOS\AuthKit\AuthKit;

$authkit = new AuthKit("sk_live_12345");
$response = $authkit->create([
	"group" => "meaningful-id", // a meaningful identifier (i.e., organizationId)
	"label" => "Friendly Label", // a human-friendly label (i.e., organizationName)
]);

echo json_encode($response);

或者如果您使用 Laravel,可以定义如下路由

<?php

use Illuminate\Support\Facades\Route;
use IntegrationOS\AuthKit\AuthKit;

Route::get('/create-embed-token', function () {
    $authkit = new AuthKit("sk_live_12345");
	
    $response = $authkit->create([
        "group" => "meaningful-id", // a meaningful identifier (i.e., organizationId)
        "label" => "Friendly Label", // a human-friendly label (i.e., organizationName)
    ]);
    
    return $response;
});

您需要将 API 密钥替换为您自己的,这将告诉前端您希望向用户提供哪些集成。

您还需要根据您组织和管理用户连接账户的方式填写 GroupLabel 字段。组尤其重要,因为它用于生成用户成功连接账户后唯一的 连接密钥

完整文档

请参阅官方的 IntegrationOS AuthKit 文档,以更全面地了解 IntegrationOS AuthKit。