4 * Authentication adapter for Amazon OAuth2.
6 final class PhutilAmazonAuthAdapter
extends PhutilOAuthAuthAdapter
{
8 public function getAdapterType() {
12 public function getAdapterDomain() {
16 public function getAccountID() {
17 return $this->getOAuthAccountData('user_id');
20 public function getAccountEmail() {
21 return $this->getOAuthAccountData('email');
24 public function getAccountName() {
28 public function getAccountImageURI() {
32 public function getAccountURI() {
36 public function getAccountRealName() {
37 return $this->getOAuthAccountData('name');
40 protected function getAuthenticateBaseURI() {
41 return 'https://www.amazon.com/ap/oa';
44 protected function getTokenBaseURI() {
45 return 'https://api.amazon.com/auth/o2/token';
48 public function getScope() {
52 public function getExtraAuthenticateParameters() {
54 'response_type' => 'code',
58 public function getExtraTokenParameters() {
60 'grant_type' => 'authorization_code',
64 protected function loadOAuthAccountData() {
65 $uri = new PhutilURI('https://api.amazon.com/user/profile');
66 $uri->replaceQueryParam('access_token', $this->getAccessToken());
68 $future = new HTTPSFuture($uri);
69 list($body) = $future->resolvex();
72 return phutil_json_decode($body);
73 } catch (PhutilJSONParserException
$ex) {
74 throw new PhutilProxyException(
75 pht('Expected valid JSON response from Amazon account data request.'),