Apple OAuth tests
This commit is contained in:
parent
7adb04bc7f
commit
6e143f7ed3
3 changed files with 35 additions and 6 deletions
|
@ -73,12 +73,12 @@ return [
|
||||||
'enabled' => true,
|
'enabled' => true,
|
||||||
'mock' => false,
|
'mock' => false,
|
||||||
],
|
],
|
||||||
// 'apple' => [
|
'apple' => [
|
||||||
// 'developers' => 'https://developer.apple.com/',
|
'developers' => 'https://developer.apple.com/',
|
||||||
// 'icon' => 'icon-apple',
|
'icon' => 'icon-apple',
|
||||||
// 'enabled' => false,
|
'enabled' => true,
|
||||||
// 'mock' => false,
|
'mock' => false,
|
||||||
// ],
|
],
|
||||||
'amazon' => [
|
'amazon' => [
|
||||||
'developers' => 'https://developer.amazon.com/apps-and-games/services-and-apis',
|
'developers' => 'https://developer.amazon.com/apps-and-games/services-and-apis',
|
||||||
'icon' => 'icon-amazon',
|
'icon' => 'icon-amazon',
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 3.5 KiB |
|
@ -138,4 +138,33 @@ class Apple extends OAuth2
|
||||||
|
|
||||||
return $this->user;
|
return $this->user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getToken($p8)
|
||||||
|
{
|
||||||
|
$keyfile = 'AuthKey_AABBCC1234.p8'; # <- Your AuthKey file
|
||||||
|
$keyid = '4LFF7TZ6Q5'; # <- Your Key ID
|
||||||
|
$teamid = 'YJHMCSNREU'; # <- Your Team ID (see Developer Portal)
|
||||||
|
$bundleid = 'test2.appwrite.io'; # <- Your Bundle ID
|
||||||
|
$url = 'https://api.development.push.apple.com'; # <- development url, or use http://api.push.apple.com for production environment
|
||||||
|
$token = 'e2c48ed32ef9b018........'; # <- Device Token
|
||||||
|
|
||||||
|
function base64($data) {
|
||||||
|
return rtrim(strtr(base64_encode(json_encode($data)), '+/', '-_'), '=');
|
||||||
|
}
|
||||||
|
|
||||||
|
$message = '{"aps":{"alert":"Hi there!","sound":"default"}}';
|
||||||
|
|
||||||
|
$key = openssl_pkey_get_private('file://'.$keyfile);
|
||||||
|
|
||||||
|
$header = ['alg'=>'ES256', 'kid'=>$keyid];
|
||||||
|
$claims = ['iss'=>$teamid, 'iat'=>time()];
|
||||||
|
|
||||||
|
$header_encoded = base64($header);
|
||||||
|
$claims_encoded = base64($claims);
|
||||||
|
|
||||||
|
$signature = '';
|
||||||
|
openssl_sign($header_encoded . '.' . $claims_encoded, $signature, $key, 'sha256');
|
||||||
|
$jwt = $header_encoded . '.' . $claims_encoded . '.' . base64_encode($signature);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue