mirror of
https://github.com/appwrite/appwrite
synced 2026-05-23 17:08:45 +00:00
fix: request issues and permissions
This commit is contained in:
parent
3bd8405deb
commit
2c453d5fd9
2 changed files with 14 additions and 12 deletions
|
|
@ -196,9 +196,9 @@ abstract class OAuth2
|
||||||
|
|
||||||
if (!empty($payload)) {
|
if (!empty($payload)) {
|
||||||
\curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
|
\curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
|
||||||
|
$headers[] = 'Content-length: ' . \strlen($payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
$headers[] = 'Content-length: ' . \strlen($payload);
|
|
||||||
\curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
\curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||||
|
|
||||||
// Send the request & save response to $response
|
// Send the request & save response to $response
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ class Figma extends OAuth2
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected array $scopes = [
|
protected array $scopes = [
|
||||||
'file_read'
|
'current_user:read'
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -44,7 +44,7 @@ class Figma extends OAuth2
|
||||||
'response_type' => 'code',
|
'response_type' => 'code',
|
||||||
'client_id' => $this->appID,
|
'client_id' => $this->appID,
|
||||||
'redirect_uri' => $this->callback,
|
'redirect_uri' => $this->callback,
|
||||||
'scope' => \implode(',', $this->getScopes()),
|
'scope' => \implode(' ', $this->getScopes()),
|
||||||
'state' => \json_encode($this->state)
|
'state' => \json_encode($this->state)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
@ -57,14 +57,15 @@ class Figma extends OAuth2
|
||||||
protected function getTokens(string $code): array
|
protected function getTokens(string $code): array
|
||||||
{
|
{
|
||||||
if (empty($this->tokens)) {
|
if (empty($this->tokens)) {
|
||||||
$headers = ['Content-Type: application/x-www-form-urlencoded'];
|
$headers = [
|
||||||
|
'Content-Type: application/x-www-form-urlencoded',
|
||||||
|
'Authorization: Basic ' . \base64_encode($this->appID . ':' . $this->appSecret)
|
||||||
|
];
|
||||||
$this->tokens = \json_decode($this->request(
|
$this->tokens = \json_decode($this->request(
|
||||||
'POST',
|
'POST',
|
||||||
'https://www.figma.com/api/oauth/token',
|
'https://api.figma.com/v1/oauth/token',
|
||||||
$headers,
|
$headers,
|
||||||
\http_build_query([
|
\http_build_query([
|
||||||
'client_id' => $this->appID,
|
|
||||||
'client_secret' => $this->appSecret,
|
|
||||||
'redirect_uri' => $this->callback,
|
'redirect_uri' => $this->callback,
|
||||||
'code' => $code,
|
'code' => $code,
|
||||||
'grant_type' => 'authorization_code'
|
'grant_type' => 'authorization_code'
|
||||||
|
|
@ -82,14 +83,15 @@ class Figma extends OAuth2
|
||||||
*/
|
*/
|
||||||
public function refreshTokens(string $refreshToken): array
|
public function refreshTokens(string $refreshToken): array
|
||||||
{
|
{
|
||||||
$headers = ['Content-Type: application/x-www-form-urlencoded'];
|
$headers = [
|
||||||
|
'Content-Type: application/x-www-form-urlencoded',
|
||||||
|
'Authorization: Basic ' . \base64_encode($this->appID . ':' . $this->appSecret)
|
||||||
|
];
|
||||||
$this->tokens = \json_decode($this->request(
|
$this->tokens = \json_decode($this->request(
|
||||||
'POST',
|
'POST',
|
||||||
'https://www.figma.com/api/oauth/refresh',
|
'https://api.figma.com/v1/oauth/refresh',
|
||||||
$headers,
|
$headers,
|
||||||
\http_build_query([
|
\http_build_query([
|
||||||
'client_id' => $this->appID,
|
|
||||||
'client_secret' => $this->appSecret,
|
|
||||||
'refresh_token' => $refreshToken
|
'refresh_token' => $refreshToken
|
||||||
])
|
])
|
||||||
), true);
|
), true);
|
||||||
|
|
@ -162,7 +164,7 @@ class Figma extends OAuth2
|
||||||
protected function getUser(string $accessToken): array
|
protected function getUser(string $accessToken): array
|
||||||
{
|
{
|
||||||
if (empty($this->user)) {
|
if (empty($this->user)) {
|
||||||
$headers = ['Authorization: Bearer ' . \urlencode($accessToken)];
|
$headers = ['Authorization: Bearer ' . $accessToken];
|
||||||
$user = $this->request(
|
$user = $this->request(
|
||||||
'GET',
|
'GET',
|
||||||
'https://api.figma.com/v1/me',
|
'https://api.figma.com/v1/me',
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue