PHP code example of idaaser / oneid-jwt-auth-php

1. Go to this page and download the library: Download idaaser/oneid-jwt-auth-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

idaaser / oneid-jwt-auth-php example snippets


composer 



use oneid\jwt_auth\UserInfoBuilder;
use oneid\jwt_auth\JwtConfig;
use oneid\jwt_auth\JwtAuth;

$issuer = "oneid-jinrruan";
$loginUrl = "https://oauth2.eid-6.account.tencentcs.com/v1/sso/jwtp/1102878596482998272/1151383032381308928/kit/{app_type}";
$jwtConfig = new JwtConfig($primaryKey, $issuer, $loginUrl);

$builder = new UserInfoBuilder("user_id-123");
$extension = array("code"=>"1234", "state"=>"4321", "otherParam"=>"other");
$userInfo = $builder->setName("jinrruan")
    ->setPreferredUsername("haha")
    ->setMobile("13007149***")
    ->setEmail("[email protected]")
    ->setExtension($extension)->build();

$param = array("code"=>"12+3@?4", "state"=>"43+21", "otherParam"=>"other");
echo JwtAuth::generateLoginUrlWithUserInfo($jwtConfig, $userInfo, App_Tencent_Meeting, $param).PHP_EOL;

$claims = array("name"=>"jinrruan", "preferredUsername"=>"haha", "mobile"=>"13007149***", "email"=>"[email protected]");

echo JwtAuth::generateLoginUrlWithClaims($jwtConfig, $claims, App_Tencent_Docs, $param).PHP_EOL;