Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## 30.1.0

* Added: optional `state` parameter on `createOAuth2Token`, returned unchanged on the success and failure URLs

## 30.0.0

* Stable release of the dedicated database APIs: `mysql`, `postgresql`, `mongo`, `documentsDB`, and `vectorsDB` services, previously released as release candidates
Expand Down
1 change: 1 addition & 0 deletions docs/account.md
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,7 @@ A user is limited to 10 active sessions at a time by default. [Learn more about
| success | string | URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. | |
| failure | string | URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. | |
| scopes | array | A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long. | [] |
| state | string | An opaque value your app generates and keeps, for example in a cookie. It is returned unchanged as the `state` query parameter on the success and failure URLs, so your app can check that the sign-in it receives is one it started. Printable ASCII only (RFC 6749 Appendix A.5). Max length: 256 chars. | |


```http request
Expand Down
3 changes: 2 additions & 1 deletion docs/examples/account/create-o-auth-2-token.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ $result = $account->createOAuth2Token(
provider: OAuthProvider::AMAZON(),
success: 'https://example.com', // optional
failure: 'https://example.com', // optional
scopes: [] // optional
scopes: [], // optional
state: '<STATE>' // optional
);
```
4 changes: 2 additions & 2 deletions src/Appwrite/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ class Client
*
*/
protected array $headers = [
'user-agent' => 'AppwritePHPSDK/30.0.0 ()',
'user-agent' => 'AppwritePHPSDK/30.1.0 ()',
'x-sdk-name' => 'PHP',
'x-sdk-platform' => 'server',
'x-sdk-language' => 'php',
'x-sdk-version' => '30.0.0',
'x-sdk-version' => '30.1.0',
];

/**
Expand Down
6 changes: 5 additions & 1 deletion src/Appwrite/Services/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -1630,7 +1630,7 @@ public function createMagicURLToken(string $userId, string $email, ?string $url
*
* @throws AppwriteException
*/
public function createOAuth2Token(OAuthProvider $provider, ?string $success = null, ?string $failure = null, ?array $scopes = null): string
public function createOAuth2Token(OAuthProvider $provider, ?string $success = null, ?string $failure = null, ?array $scopes = null, ?string $state = null): string
{
$apiPath = str_replace(
['{provider}'],
Expand All @@ -1653,6 +1653,10 @@ public function createOAuth2Token(OAuthProvider $provider, ?string $success = nu
$apiParams['scopes'] = $scopes;
}

if (!is_null($state)) {
$apiParams['state'] = $state;
}

$apiHeaders = [];
$apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project');
$apiHeaders['accept'] = 'text/html';
Expand Down
Loading