kasperrt / oauth2-client
带有Bearer令牌的OAuth2客户端
此包的规范存储库似乎已消失,因此该包已被冻结。
This package is not auto-updated.
Last update: 2023-03-27 07:41:09 UTC
README
此客户端是为授权代码流和当前作为授权选项的Bearer而制作的。
要使用此通用OAuth2客户端类,请包含它
require_once('OAuth2Client.php');
$oauth2 = new OAuth2([
"client_id" => $client_id,
"client_secret" => $client_secret,
"redirect_uri" => $redirect_uri,
"auth" => $auth,
"token" => $token,
"authorization_type" => $authorization_type,
"session" => $session,
"verify" => $verify,
"grant_type" => $grant_type,
"response_type" => $response_type,
"scope" => $scope
]);
(string) $client_id
是OAuth2应用程序的客户端ID
(string) $client_secret
是OAuth2应用程序的客户端密钥
(string) $redirect_uri
是OAuth2应用程序指定的重定向URI
(string) $auth
是授权的完整URL
(string) $token
是完整令牌URL
可选 -
(string) $authorization_type
默认为Bearer
(boolean) $session
指定是否将状态保存到_SESSION存储中,默认为false
(boolean) $verify
是否验证主机和同伴的SSL,默认为true
(string) $grant_type
默认为'authorization_code'
(string) $response_type
默认为"code"
(string) $scope
默认为""
开始重定向阶段
$oauth2->redirect($state);
($state默认为false)
获取访问令牌
$oauth2->get_access_token();
返回access_token。
(可选值是$state,用于与_SESSION变量进行比较)
获取身份
$oauth->get_identity($access_token, $user_url);
(string) $user_url
是获取信息的端点,例如:https://auth.dataporten.no/userinfo
返回OAuth2提供商返回的身份对象。