Error Unauthorized

  • 0
  • Auth
  • Web
14 Apr, 2024, 03:10

I tried the C# SDK and was getting the error below:

Error Unauthorized: {"message":" (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.


builder.Services.AddHttpClient<IAuthService, AuthService>(client => { client.BaseAddress = new Uri(""); 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);
    // 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.

- Developer encountered an "Error Unauthorized" with Appwrite API. - API key should not be included in the initialization. - SDK on Github is not being updated, so developer switched to REST API but encountered the same error. - Need to update the initialization code to exclude the API key. - Once this issue is resolved, developer plans to go back to using Supabase.
14 Apr, 2024, 03:29

I got it to work finally. Apparently you dont include the API key in the initialization. It works if I comment that out.


Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more