#1106 Using C# SCRAM Authentication with .NET ProjectHaystack.Client

Gideon Noya Thu 21 Mar

Can Someone help me with the problem I'm facing when trying to create a session of SkySpark using the SCRAM authentication inside the C# ProjectHaystack.Client NuGet package?

using System.Threading.Tasks;
using ProjectHaystack.Auth;

namespace ProjectHaystack.Client
{
    class Program
    {
        static async Task Main(string[] args)
        {
            var user = "validUsername";
            var pass = "validPassword";
            var uri = new Uri("https://<domain>/api/<proj>");
            var auth = new ScramAuthenticator(user, pass);
            // auth.AddLegacySpaceToProof = true;
            var client = new HaystackClient(auth, uri);
            await client.OpenAsync();
        }
    }
}

I get this error:

Unhandled exception. System.InvalidOperationException: Cannot get authentication header, server response was: 403
   at ProjectHaystack.Auth.ScramAuthenticator.SendFinal(HttpClient client, Uri authUrl)
   at ProjectHaystack.Auth.ScramAuthenticator.Authenticate(HttpClient client, Uri authUrl)
   at ProjectHaystack.Auth.AutodetectAuthenticator.Authenticate(HttpClient client, Uri authUrl)
   at ProjectHaystack.Client.HaystackClient.OpenAsync()
   at ProjectHaystack.Client.Program.Main(String[] args) in /Users/gideon/Documents/CSharpProjects/SkySparkTest/Program.cs:line 20
   at ProjectHaystack.Client.Program.<Main>(String[] args)

I get this also when using auth.AddLegacySpaceToProof = true; And when I try to use just https://<domain>/api/ without the project, I get a 404 server error I also tried to use the AutodetectAuthenticator but that gives the same result

The 403 server error means it's forbidden but I don't know why because the project is accessible by the user

Login or Signup to reply.