animus-coop/apple-laravel-authorization-code

使用苹果登录按钮的结果码获取用户数据

dev-main 2020-11-18 14:13 UTC

This package is auto-updated.

Last update: 2024-09-18 22:52:15 UTC


README

N|Solid

入门!

composer require apple-laravel-authorization-code

在 config/app.php 中添加服务提供者

'providers' => [
   ...
    AnimusCoop\AppleTokenAuth\AppleTokenAuthServiceProvider::class,
]

使用

控制器。

use AnimusCoop\AppleTokenAuth\Classes\AppleAuth;
$data = [
   "client_id" => "",
   "team_id"   => "",
   "key_id"    => "",
   "key"       => storage_path('AuthKey.p8'), //path where is your p8 key example if your key is in storage
   "code"      => "" //code sended by your front end guy
];

$appleAuth = new AppleAuth($data);

// if you need only the jwt signed with your p8 key file

$jwt = $appleAuth->getJwtSigned();

// Refresh Token and get user Data
$user = $appleAuth->getUserData();

响应 getUserData()

[
  "authorization" => {
    "access_token": ""
    "token_type": "Bearer"
    "expires_in": 3600
    "refresh_token": ""
    "id_token": ""
  }
  "user" => {
    "iss": "https://appleid.apple.com"
    "aud": "your client id"
    "exp": 1605393470
    "iat": 1605307070
    "sub": ""
    "at_hash": ""
    "email": "isaias@animus.com.ar"
    "email_verified": "true"
    "auth_time": 1605307067
    "nonce_supported": true
  }
]