From 0c38f1db08d560e32cc88dffeb5a9d419a41dbe5 Mon Sep 17 00:00:00 2001 From: Wess Cope Date: Mon, 18 Jul 2022 10:14:51 -0400 Subject: [PATCH] Delete etsy.php --- src/Appwrite/Auth/OAuth2/etsy.php | 212 ------------------------------ 1 file changed, 212 deletions(-) delete mode 100644 src/Appwrite/Auth/OAuth2/etsy.php diff --git a/src/Appwrite/Auth/OAuth2/etsy.php b/src/Appwrite/Auth/OAuth2/etsy.php deleted file mode 100644 index 5a8db1cd59..0000000000 --- a/src/Appwrite/Auth/OAuth2/etsy.php +++ /dev/null @@ -1,212 +0,0 @@ -pkce)) { - $this->pkce = \bin2hex(\random_bytes(rand(43, 128))); - } - - return $this->pkce; - } - - /** - * @return string - */ - public function getName(): string - { - return 'etsy'; - } - - /** - * @return string - */ - public function getLoginURL(): string - { - return 'https://www.etsy.com/oauth/connect/oauth/authorize?' . \http_build_query([ - 'client_id' => $this->appID, - 'redirect_uri' => $this->callback, - 'response_type' => 'code', - 'state' => \json_encode($this->state), - 'scope' => $this->scopes, - 'code_challenge' => $this->getPKCE(), - 'code_challenge_method' => 'S256', - ]); - } - - /** - * @param string $code - * - * @return array - */ - protected function getTokens(string $code): array - { - if (empty($this->tokens)) { - $headers = ['Content-Type: application/x-www-form-urlencoded']; - - $this->tokens = \json_decode($this->request( - 'POST', - $this->endpoint . '/oauth/token', - $headers, - \http_build_query([ - 'grant_type' => 'authorization_code', - 'client_id' => $this->appID, - 'redirect_uri' => $this->callback, - 'code' => $code, - 'code_verifier' => $this->getPKCE(), - ]) - ), true); - } - - return $this->tokens; - } - - /** - * @param string $refreshToken - * - * @return array - */ - public function refreshTokens(string $refreshToken): array - { - $headers = ['Content-Type: application/x-www-form-urlencoded']; - - $this->tokens = \json_decode($this->request( - 'POST', - $this->endpoint . '/oauth/token', - $headers, - \http_build_query([ - 'grant_type' => 'refresh_token', - 'client_id' => $this->appID, - 'refresh_token' => $refreshToken, - ]) - ), true); - - if (empty($this->tokens['refresh_token'])) { - $this->tokens['refresh_token'] = $refreshToken; - } - - return $this->tokens; - } - - /** - * @param $accessToken - * - * @return string - */ - public function getUserID(string $accessToken): string - { - $components = explode('.', $accessToken); - - return $components[0]; - } - - /** - * @param $accessToken - * - * @return string - */ - public function getUserEmail(string $accessToken): string - { - return $this->getUser($accessToken)['primary_email']; - } - - /** - * Check if the OAuth email is verified - * - * If present, the email is verified. This was verfied through a manual Stripe sign up process - * - * @param string $accessToken - * - * @return bool - */ - public function isEmailVerified(string $accessToken): bool - { - $email = $this->getUserEmail($accessToken); - - return !empty($email); - } - - /** - * @param $accessToken - * - * @return string - */ - public function getUserName(string $accessToken): string - { - return $this->getUser($accessToken)['login_name']; - } - - /** - * @param string $accessToken - * - * @return array - */ - protected function getUser(string $accessToken) - { - if (!empty($this->user)) { - return $this->user; - } - - $headers = ['Authorization: Bearer ' . $accessToken]; - - $this->user = \json_decode($this->request( - 'GET', - 'https://api.etsy.com/v3/application/users/' . $this->getUserID($accessToken), - ), true); - - return $this->user; - } -}