box / box-windows-sdk-v2

Windows SDK for v2 of the Box API. The SDK is built upon .NET Framework 4.5

Home Page:https://developer.box.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Box.V2 boxClient.Auth.AuthenticateAsync is throwing "An error occurred while sending the request"

schandra09net opened this issue · comments

Hello Team,

We are using Box.V2 in my C# WPF application, and while invoking below method getting this exception ,

Intialization to get AuthCode:
var boxConfig = new BoxConfig(_boxAppClientID, _boxAppClientSecret, new Uri(_boxAppReturnUrl));
_boxClient = new BoxClient(boxConfig, session);

Try to get AccessToken:
image
{"An error occurred while sending the request."}
Data: {System.Collections.ListDictionaryInternal}
HResult: -2146233088
HelpLink: null
InnerException: {"The request was aborted: Could not create SSL/TLS secure channel."}
Message: "An error occurred while sending the request."
Source: "Microsoft.Threading.Tasks"
StackTrace: " at Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(Task task)\r\n at Box.V2.Auth.AuthRepository.d__17.MoveNext()\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n at Content.ContentProviderModule.Providers.BoxContentProvider.<b__14_0>d.MoveNext() in D:\Comapny\Content\Modules\ContentProviderModule\Providers\BoxContentProvider.cs:line 119"
TargetSite: {Void ThrowForNonSuccess(System.Threading.Tasks.Task)}

Can you please let me know?

Hi @schandra09net,

It's look like due to TLS conflict you are not able to make a connection to the server.

  1. Can you specify what Windows version and .NET framework you are using?
  2. Is there any place in your WPF app where you set ServicePointManager.SecurityProtocol property?
  3. Can you also put this line Console.WriteLine(ServicePointManager.SecurityProtocol); in you catch blok and show us what it prints for further investigation?

@arjankowski

Hi @arjankowski:

Thanks for your reply, and answers below

  1. Can you specify what Windows version and .NET framework you are using?
    2021-11-15_20h28_38

2021-11-15_20h29_11

  1. Is there any place in your WPF app where you set ServicePointManager.SecurityProtocol property?
    No results found in Visual Studio with search "ServicePointManager.SecurityProtocol" or "ServicePointManager" or "ServicePointManager.SecurityProtocol"

  2. Can you also put this line Console.WriteLine(ServicePointManager.SecurityProtocol); in you catch blok and show us what it prints for further investigation?

2021-11-15_20h37_10

Please suggest.

Hi @arjankowski:

After adding this line in try block, issue is resolved, and getting all the box items.
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

image

Thank you.

commented

This issue has been automatically marked as stale because it has not been updated in the last 30 days. It will be closed if no further activity occurs within the next 7 days. Feel free to reach out or mention Box SDK team member for further help and resources if they are needed.