Skip to content

Authentication Issue #5

@stephanie-rimel

Description

@stephanie-rimel

So i am trying to use this is a Blazor Server .Net 8 Project and am having an issue getting the authentication to work. Everytime i try to submit the trade, i receive the Unauthorized response.

I am registering the service like this in my Program.cs
var configuration = new CoinbaseATConfiguration(

    apiKey, apiSecret
);

builder.Services.AddSingleton<ICoinbaseATConfiguration>(configuration);
builder.Services.AddSingleton<ICoinbaseATClient, CoinbaseATClient>();
 // builder.Services.AddSingleton<CoinbaseATClient>();

I am injecting the CoinbaseAtClient like this in my .Razor page:

@inject ICoinbaseATClient CoinbaseATClient

@code {
// ...
var result = await AtService.CreatMarketOrderAsync(Guid.NewGuid().ToString(), crypto.ProductId, OrderSide.BUY.ToString(), order_configuration);
var acct = await CoinbaseATClient.ProductsService.GetProductAsync("BTC-USD");
}

and here is my exception
---> System.Exception: Exception of type 'System.Exception' was thrown. --- End of inner exception stack trace --- at CoinbaseAT.Services.Abstractions.CoinbaseATService.SendHttpRequestMessageAsync(HttpMethod httpMethod, String requestPath, String contentBody) at CoinbaseAT.Services.Abstractions.CoinbaseATService.SendServiceCall[T](HttpMethod httpMethod, String requestPath, String contentBody) at CoinbaseAT.Services.ProductsService.GetProductAsync(String product_id) at BotTrading.Shared.CryptoComponent.CryptoComponent.SubmitPosition(String orderType, OrderSide orderSide) in C:\Users\Stephanie\source\repos\BotTrading\BotTrading\Shared\CryptoComponent\CryptoComponent.razor:line 123

When i try to query an endpoint that doesnt require authentication i get this error:
System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.Http.HttpIOException: The response ended prematurely. (ResponseEnded) at System.Net.Http.HttpConnection.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) --- End of inner exception stack trace --- at System.Net.Http.HttpConnection.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken) at System.Net.Http.DiagnosticsHandler.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at Microsoft.Extensions.Http.Logging.LoggingHttpMessageHandler.<SendCoreAsync>g__Core|5_0(HttpRequestMessage request, Boolean useAsync, CancellationToken cancellationToken) at Microsoft.Extensions.Http.Logging.LoggingScopeHttpMessageHandler.<SendCoreAsync>g__Core|5_0(HttpRequestMessage request, Boolean useAsync, CancellationToken cancellationToken) at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken) at CoinbaseAT.Services.Abstractions.CoinbaseATService.SendHttpRequestMessageAsync(HttpMethod httpMethod, String requestPath, String contentBody) at CoinbaseAT.Services.Abstractions.CoinbaseATService.SendServiceCall[T](HttpMethod httpMethod, String requestPath, String contentBody) at CoinbaseAT.Services.ProductsService.GetProductAsync(String product_id) at BotTrading.Shared.CryptoComponent.CryptoComponent.SubmitPosition(String orderType, OrderSide orderSide) in C:\Users\Stephanie\source\repos\BotTrading\BotTrading\Shared\CryptoComponent\CryptoComponent.razor:line

I have already verified that my apiKey and apiSecret are correct and that they are being passeed into my CoinbaseATConfiguration, I am able to do api calls with these same credentials with another library package. I cant figure out what is causing this. I have the same problem in both the razor file and in the service file.

I even tried it with the ICoinbaseAtClient for good measure, and tried registering the CoinbaseAtClient independntly as well in my Program.cs to no avail. Do you have any hints on what could resolve this issue? I really love the project and how thourough it is i do not want to remove it because nothing else is this complete. Very nice work, and thank you for any help you can offer!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions