friendship ended with social-app. php is my new best friend
1<?php 2/** 3 * Class Amazon 4 * 5 * @created 10.08.2018 6 * @author Smiley <smiley@chillerlan.net> 7 * @copyright 2018 Smiley 8 * @license MIT 9 * 10 * @noinspection PhpUnused 11 */ 12declare(strict_types=1); 13 14namespace chillerlan\OAuth\Providers; 15 16use chillerlan\OAuth\Core\{AuthenticatedUser, CSRFToken, OAuth2Provider, TokenRefresh, UserInfo}; 17 18/** 19 * Login with Amazon for Websites (OAuth2) 20 * 21 * @link https://developer.amazon.com/docs/login-with-amazon/web-docs.html 22 * @link https://developer.amazon.com/docs/login-with-amazon/conceptual-overview.html 23 */ 24class Amazon extends OAuth2Provider implements CSRFToken, TokenRefresh, UserInfo{ 25 26 public const IDENTIFIER = 'AMAZON'; 27 28 public const SCOPE_PROFILE = 'profile'; 29 public const SCOPE_PROFILE_USER_ID = 'profile:user_id'; 30 public const SCOPE_POSTAL_CODE = 'postal_code'; 31 32 public const DEFAULT_SCOPES = [ 33 self::SCOPE_PROFILE, 34 self::SCOPE_PROFILE_USER_ID, 35 ]; 36 37 protected string $authorizationURL = 'https://www.amazon.com/ap/oa'; 38 protected string $accessTokenURL = 'https://www.amazon.com/ap/oatoken'; 39 protected string $apiURL = 'https://api.amazon.com'; 40 protected string|null $applicationURL = 'https://developer.amazon.com/loginwithamazon/console/site/lwa/overview.html'; 41 protected string|null $apiDocs = 'https://developer.amazon.com/docs/login-with-amazon/web-docs.html'; 42 43 /** @codeCoverageIgnore */ 44 public function me():AuthenticatedUser{ 45 $json = $this->getMeResponseData('/user/profile'); 46 47 $userdata = [ 48 'data' => $json, 49 'displayName' => $json['name'], 50 'email' => $json['email'], 51 'id' => $json['user_id'], 52 ]; 53 54 return new AuthenticatedUser($userdata); 55 } 56 57}