sudtech/sud-gip-auth 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sudtech/sud-gip-auth

最新稳定版本:v1.0.0.1

Composer 安装命令:

composer require sudtech/sud-gip-auth

包简介

PHP implementation of Sud GIP authentication system with JWT support

README 文档

README

Introduction

The Sud GIP Auth PHP SDK is a PHP library designed for implementing the Sud GIP authentication system, with support for JWT (JSON Web Token) authentication. This SDK provides functions such as generating authentication codes, server-to-server tokens (SSTokens), verifying tokens, and retrieving user IDs, making it convenient for developers to integrate Sud GIP's authentication services into PHP projects.

Features

  • Token Generation: Supports generating authentication codes and SSTokens, with the ability to set expiration durations.
  • Token Verification: Verifies the validity of authentication codes and SSTokens.
  • User ID Retrieval: Retrieves user IDs using authentication codes or SSTokens.

Installation

You can install this SDK using Composer. Run the following command in your project's root directory:

    composer require sudtechnology/sud-gip-auth-php

Usage

Initialization

First, you need to instantiate the SudGIPAuth class and pass in your application ID and application secret:

<?php
require 'vendor/autoload.php';

use Sud\Gip\Api\SudGIPAuth;

$appId = 'your_app_id';
$appSecret = 'your_app_secret';

$auth = new SudGIPAuth($appId, $appSecret);

Get Authentication Code

$uid = 'user_id';
$code = $auth->getCode($uid);

echo "Code: " . $code->code . "\n";
echo "Expire Date: " . $code->expireDate . "\n";

Get Server-to-Server Token (SSToken)

$uid = 'user_id';
$ssToken = $auth->getSSToken($uid);

echo "SSToken: " . $ssToken->token . "\n";
echo "Expire Date: " . $ssToken->expireDate . "\n";

Get User ID by Authentication Code

$code = 'your_auth_code';
$uidResponse = $auth->getUidByCode($code);

if ($uidResponse->isSuccess) {
    echo "User ID: " . $uidResponse->uid . "\n";
} else {
    echo "Error Code: " . $uidResponse->errorCode . "\n";
}

Get User ID by SSToken

$ssToken = 'your_sstoken';
$uidResponse = $auth->getUidBySSToken($ssToken);

if ($uidResponse->isSuccess) {
    echo "User ID: " . $uidResponse->uid . "\n";
} else {
    echo "Error Code: " . $uidResponse->errorCode . "\n";
}

Error Codes

Error Code Description
0 Success
1001 Token creation failed
1002 Token verification failed
1003 Token decoding failed
1004 Token is invalid
1005 Token has expired
1101 App data is invalid
9999 Unknown error

License

This project is licensed under the MIT License. See the LICENSE file for details.

统计信息

  • 总下载量: 6
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-07-31

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固