Tinkoff / investAPI

395 stars 136 forks source link

Invest-api-csharp sample не работает #137

Closed FreePhoenix888 closed 2 years ago

FreePhoenix888 commented 2 years ago

Склонил репозиторий. Ввёл токен как в документации вместо <token>:

cd Tinkoff.InvestApi.Sample
dotnet user-secrets set "AccessToken" "<token>"
$ dotnet user-secrets set "AccessToken" "my_sandbox_token"
Successfully saved AccessToken = my_sandbox_token to the secret store.

Ошибка:

/home/freephoenix888/Documents/Programming/invest-api-csharp-sdk/Tinkoff.InvestApi.Sample/bin/Debug/net6.0/Tinkoff.InvestApi.Sample
info: System.Net.Http.HttpClient.Default.LogicalHandler[100]
      Start processing HTTP request POST https://invest-public-api.tinkoff.ru/tinkoff.public.invest.api.contract.v1.UsersService/GetAccounts
info: System.Net.Http.HttpClient.Default.ClientHandler[100]
      Sending HTTP request POST https://invest-public-api.tinkoff.ru/tinkoff.public.invest.api.contract.v1.UsersService/GetAccounts
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
      Content root path: /home/freephoenix888/Documents/Programming/invest-api-csharp-sdk/Tinkoff.InvestApi.Sample
info: System.Net.Http.HttpClient.Default.ClientHandler[101]
      Received HTTP response after 505.0983ms - OK
info: System.Net.Http.HttpClient.Default.LogicalHandler[101]
      End processing HTTP request after 527.9359ms - OK
info: Grpc.Net.Client.Internal.GrpcCall[3]
      Call failed with gRPC error status. Status code: 'Unauthenticated', Message: '(null)'.
fail: Microsoft.Extensions.Hosting.Internal.Host[9]
      BackgroundService failed
      Grpc.Core.RpcException: Status(StatusCode="Unauthenticated", Detail="")
         at Grpc.Net.Client.Internal.Retry.RetryCallBase`2.GetResponseAsync()
         at Tinkoff.InvestApi.Sample.UsersServiceSample.GetUserInfoDescriptionAsync(CancellationToken cancellationToken) in /home/freephoenix888/Documents/Programming/invest-api-csharp-sdk/Tinkoff.InvestApi.Sample/UsersServiceSample.cs:line 17
         at Tinkoff.InvestApi.Sample.AsyncSample.ExecuteAsync(CancellationToken stoppingToken) in /home/freephoenix888/Documents/Programming/invest-api-csharp-sdk/Tinkoff.InvestApi.Sample/AsyncSample.cs:line 18
         at Microsoft.Extensions.Hosting.Internal.Host.TryExecuteBackgroundServiceAsync(BackgroundService backgroundService)
crit: Microsoft.Extensions.Hosting.Internal.Host[10]
      The HostOptions.BackgroundServiceExceptionBehavior is configured to StopHost. A BackgroundService has thrown an unhandled exception, and the IHost instance is stopping. To avoid this behavior, configure this to Ignore; however the BackgroundService will not be restarted.
      Grpc.Core.RpcException: Status(StatusCode="Unauthenticated", Detail="")
         at Grpc.Net.Client.Internal.Retry.RetryCallBase`2.GetResponseAsync()
         at Tinkoff.InvestApi.Sample.UsersServiceSample.GetUserInfoDescriptionAsync(CancellationToken cancellationToken) in /home/freephoenix888/Documents/Programming/invest-api-csharp-sdk/Tinkoff.InvestApi.Sample/UsersServiceSample.cs:line 17
         at Tinkoff.InvestApi.Sample.AsyncSample.ExecuteAsync(CancellationToken stoppingToken) in /home/freephoenix888/Documents/Programming/invest-api-csharp-sdk/Tinkoff.InvestApi.Sample/AsyncSample.cs:line 18
         at Microsoft.Extensions.Hosting.Internal.Host.TryExecuteBackgroundServiceAsync(BackgroundService backgroundService)
info: Microsoft.Hosting.Lifetime[0]
      Application is shutting down...

Токен для песочницы был выставлен согласно документации

FreePhoenix888 commented 2 years ago

Проблема была в том, что использовался токен песочницы