定制 andalisolutions/oauth2-anaf 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

andalisolutions/oauth2-anaf

最新稳定版本:v1.0.0

Composer 安装命令:

composer require andalisolutions/oauth2-anaf

包简介

Anaf OAuth 2.0 support for the PHP League's OAuth 2.0 Client

README 文档

README

OAuth 2.0 ANAF

GitHub Workflow Status (main) Total Downloads Latest Version License

ANAF Provider for OAuth 2.0 Client

This package provides ANAF OAuth 2.0 support for the PHP League's OAuth 2.0 Client.

Installation

To install, use composer:

composer require andalisolutions/oauth2-anaf

Usage

Usage is the same as The League's OAuth client, using \Anaf\OAuth2\Client\Provider\AnafProvider as the provider.

Authorization Code Flow

$provider = new Anaf\OAuth2\Client\Provider\AnafProvider(
    clientId: '{anaf-client-id}',
    clientSecret: '{anaf-client-secret}',
    redirectUrl: 'https://example.com/callback-url',
);

// Redirect to the authorization URL
$authorizationUrl = $provider->getAuthorizationUrl();
header('Location: ' . $authorizationUrl);

// This part will be in your callback script
if (isset($_GET['code'])) {
    try {
        $accessToken = $provider->getAccessToken('authorization_code', [
            'code' => $_GET['code'],
        ]);
        // We have an access token, which we may use in authenticated
        // requests against the service provider's API.
        echo 'Access Token: ' . $accessToken->getToken() . "<br>";
        echo 'Refresh Token: ' . $accessToken->getRefreshToken() . "<br>";
        echo 'Expired in: ' . $accessToken->getExpires() . "<br>";
        echo 'Already expired? ' . ($accessToken->hasExpired() ? 'expired' : 'not expired') . "<br>";

    } catch (Exception $e) {
        // Handle errors, such as an invalid code
    }
}

Testing

composer test

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 2.3k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 18
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 18
  • Watchers: 3
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-12-29