![](https://cdn.discordapp.com/avatars/427294464696909824/2ef6ae4d668f6a269e581dcb34d268ae.webp)
I tried the C# SDK and was getting the error below:
Error Unauthorized: {"message":"app.6619a48bdcd3d3361fbc@service.cloud.appwrite.io (role: applications) missing scope (public)","code":401,"type":"general_unauthorized_scope","version":"0.12.148"}
I realized that SDK on Github is not being updated. So I switched to REST API. Same error.
Initialization:
builder.Services.AddHttpClient<IAuthService, AuthService>(client => { client.BaseAddress = new Uri("https://cloud.appwrite.io/v1"); client.DefaultRequestHeaders.Add("X-Appwrite-Project", "********************"); client.DefaultRequestHeaders.Add("X-Appwrite-Key", "*************************************"); });
My method:
public async Task<dynamic> AuthenticateUserAsync(string email, string password) { var requestBody = new { email, password };
var jsonRequestBody = JsonSerializer.Serialize(requestBody);
var httpContent = new StringContent(jsonRequestBody, Encoding.UTF8, "application/json");
var response = await _httpClient.PostAsync("/v1/account/sessions/email", httpContent);
if (response.IsSuccessStatusCode)
{
var jsonResponse = await response.Content.ReadAsStringAsync();
return JsonSerializer.Deserialize<dynamic>(jsonResponse);
}
else
{
// Handle the error
System.Diagnostics.Debug.WriteLine($"Error {response.StatusCode}: {await response.Content.ReadAsStringAsync()}");
return null;
}
}
I have made 0 progress, if I can get this fixed, will go back to Supabase.
![](https://cdn.discordapp.com/avatars/427294464696909824/2ef6ae4d668f6a269e581dcb34d268ae.webp)
I got it to work finally. Apparently you dont include the API key in the initialization. It works if I comment that out.
Recommended threads
- Server Error - 500 when Loading Messagin...
Hi, I'm self hosting on a VPS my appwrite database and was working towards setting up an SMTP server, when testing I got an error due to some mishaps with the S...
- Invalid token passed in the request by u...
Hi guys, I'm having this issue when passing the parameters userId and secret to **updateVerification**. I checked in Appwrite console and the email was verifie...
- Google Oauth: missing redirect url, appw...
I am doing Google Oauth in flutter app using Appwrite My appwrite is selfhosted running locally on my laptop in a docker container. I had my reasons to tunnel...
![](/images/bgs/pre-footer.png)