diff --git a/app/config/providers.php b/app/config/providers.php index 98ad93b30c..50369e2234 100644 --- a/app/config/providers.php +++ b/app/config/providers.php @@ -171,6 +171,16 @@ return [ // Ordered by ABC. 'beta' => false, 'mock' => false, ], + 'line' => [ + 'name' => 'Line', + 'developers' => 'https://developers.line.biz/en/docs/line-login/integrate-line-login/', + 'icon' => 'icon-line', + 'enabled' => true, + 'sandbox' => false, + 'form' => false, + 'beta' => false, + 'mock' => false, + ], 'linkedin' => [ 'name' => 'LinkedIn', 'developers' => 'https://developer.linkedin.com/', diff --git a/public/images/users/line.png b/public/images/users/line.png new file mode 100644 index 0000000000..f892e5c6e0 Binary files /dev/null and b/public/images/users/line.png differ diff --git a/src/Appwrite/Auth/OAuth2/Line.php b/src/Appwrite/Auth/OAuth2/Line.php new file mode 100644 index 0000000000..fa5b4b28b0 --- /dev/null +++ b/src/Appwrite/Auth/OAuth2/Line.php @@ -0,0 +1,140 @@ + 'code', + 'client_id' => $this->appID, + 'redirect_uri' => $this->callback, + 'state' => \json_encode($this->state), + 'scope' => \implode('%20', $this->getScopes()) + ]); + } + + /** + * @param string $code + * + * @return array + */ + protected function getTokens(string $code): array + { + if (empty($this->tokens)) { + $this->tokens = \json_decode($this->request( + 'POST', + 'https://api.line.me/oauth2/v2.1/token', + ['Content-Type: application/x-www-form-urlencoded'], + \http_build_query([ + 'grant_type' => 'authorization_code', + 'code' => $code, + 'client_id' => $this->appID, + 'client_secret' => $this->appSecret, + 'redirect_uri' => $this->callback + ]) + ), true); + } + return $this->tokens; + } + + /** + * @param string $refreshToken + * + * @return array + */ + public function refreshTokens(string $refreshToken): array + { + return []; + } + + /** + * @param string $accessToken + * + * @return string + */ + public function getUserID(string $accessToken): string + { + $user = $this->getUser($accessToken); + + return ''; + } + + /** + * @param string $accessToken + * + * @return string + */ + public function getUserEmail(string $accessToken): string + { + + return ''; + } + + /** + * Check if the OAuth email is verified + * + * @link https://docs.github.com/en/rest/users/emails#list-email-addresses-for-the-authenticated-user + * + * @param string $accessToken + * + * @return bool + */ + public function isEmailVerified(string $accessToken): bool + { + return false; + } + + /** + * @param string $accessToken + * + * @return string + */ + public function getUserName(string $accessToken): string + { + return ''; + } + + /** + * @param string $accessToken + * + * @return array + */ + protected function getUser(string $accessToken): array + { + + return ''; + } +} \ No newline at end of file