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
2 changes: 1 addition & 1 deletion Appwrite/Appwrite.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net462</TargetFrameworks>
<PackageId>Appwrite</PackageId>
<Version>8.0.0</Version>
<Version>8.1.0</Version>
<Authors>Appwrite Team</Authors>
<Company>Appwrite Team</Company>
<Description>
Expand Down
4 changes: 2 additions & 2 deletions Appwrite/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ public Client(
_headers = new Dictionary<string, string>()
{
{ "content-type", "application/json" },
{ "user-agent", $"AppwriteDotNetSDK/8.0.0 ({Environment.OSVersion.Platform}; {Environment.OSVersion.VersionString})"},
{ "user-agent", $"AppwriteDotNetSDK/8.1.0 ({Environment.OSVersion.Platform}; {Environment.OSVersion.VersionString})"},
{ "x-sdk-name", ".NET" },
{ "x-sdk-platform", "server" },
{ "x-sdk-language", "dotnet" },
{ "x-sdk-version", "8.0.0"},
{ "x-sdk-version", "8.1.0"},
{ "X-Appwrite-Response-Format", "2.0.0" }
};

Expand Down
5 changes: 3 additions & 2 deletions Appwrite/Services/Account.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1930,7 +1930,7 @@ static Models.Token Convert(Dictionary<string, object> it)
/// limits](https://appwrite.io/docs/authentication-security#limits).
/// </para>
/// </summary>
public Task<String> CreateOAuth2Token(Appwrite.Enums.OAuthProvider provider, string? success = null, string? failure = null, List<string>? scopes = null)
public Task<String> CreateOAuth2Token(Appwrite.Enums.OAuthProvider provider, string? success = null, string? failure = null, List<string>? scopes = null, string? state = null)
{
var apiPath = "/account/tokens/oauth2/{provider}"
.Replace("{provider}", provider.Value);
Expand All @@ -1939,7 +1939,8 @@ public Task<String> CreateOAuth2Token(Appwrite.Enums.OAuthProvider provider, str
{
{ "success", success },
{ "failure", failure },
{ "scopes", scopes }
{ "scopes", scopes },
{ "state", state }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Encode state as a query parameter value

This goes through Client.PrepareRequest and Extensions.ToQueryString, which escapes the assembled URI rather than individual values, leaving +, &, and # unescaped. A state such as a+b (common with base64 tokens) arrives as a b, while a&b is split into parameters, so it cannot be returned unchanged; encode query values individually before assembling the URL.

Prompt To Fix With AI
This is a comment left during a code review.
Path: Appwrite/Services/Account.cs
Line: 1943

Comment:
**Encode state as a query parameter value**

This goes through `Client.PrepareRequest` and `Extensions.ToQueryString`, which escapes the assembled URI rather than individual values, leaving `+`, `&`, and `#` unescaped. A state such as `a+b` (common with base64 tokens) arrives as `a b`, while `a&b` is split into parameters, so it cannot be returned unchanged; encode query values individually before assembling the URL.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

🟡 Minor · bug · Reply if this doesn't apply.

};

var apiHeaders = new Dictionary<string, string>()
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## 8.1.0

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

## 8.0.0

* Stable release of the dedicated database APIs: `mysql`, `postgresql`, `mongo`, `documentsDB`, and `vectorsDB` services, previously released as release candidates
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ Appwrite is an open-source backend as a service server that abstracts and simpli
Add this reference to your project's `.csproj` file:

```xml
<PackageReference Include="Appwrite" Version="8.0.0" />
<PackageReference Include="Appwrite" Version="8.1.0" />
```

You can install packages from the command line:

```powershell
# Package Manager
Install-Package Appwrite -Version 8.0.0
Install-Package Appwrite -Version 8.1.0

# or .NET CLI
dotnet add package Appwrite --version 8.0.0
dotnet add package Appwrite --version 8.1.0
```


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 @@ -15,7 +15,8 @@ await account.CreateOAuth2Token(
provider: OAuthProvider.Amazon,
success: "https://example.com", // optional
failure: "https://example.com", // optional
scopes: new List<string>() // optional
scopes: new List<string>(), // optional
state: "<STATE>" // optional
);

```
Loading