Autodesk-Forge/learn.forge.viewmodels

Error in Gettoken

Closed this issue · 5 comments

I can log in using the 3 legged authentication but once I accept the permissions then I get this error.

Error calling Gettoken: The underlying connection was closed: An unexpected error occurred on a send.

just to be clear, your question is about 3-legged, but this is the 2-legged tutorial code...right?

about the problem, it is probably happening due TLS migration, please check

https://forge.autodesk.com/blog/upcoming-forge-system-upgrade-tls-12-upgrade-date-moved-oct-31
https://forge.autodesk.com/blog/tls-12-net-developers
https://forge.autodesk.com/blog/tls-12-nodejs-developers

Here is the function that I am getting the error in. Is this 3-legged Authentication?

[HttpGet]
[Route("api/forge/oauth/url")]
public string GetOAuthURL()
{
// prepare the sign in URL
Scope[] scopes = { Scope.DataRead };
ThreeLeggedApi _threeLeggedApi = new ThreeLeggedApi();
string oauthUrl = _threeLeggedApi.Authorize(
Credentials.GetAppSetting("FORGE_CLIENT_ID"),
oAuthConstants.CODE,
Credentials.GetAppSetting("FORGE_CALLBACK_URL"),
new Scope[] { Scope.DataRead, Scope.ViewablesRead });

  return oauthUrl;
}

I just downloaded the source for 3-legged (which is NOT this repo) and compiled with VS2017, works fine. Please make sure to Rebuild the project.

https://github.com/Autodesk-Forge/learn.forge.viewhubmodels/archive/net.zip

There's a fair chance, that this error happens, because the API server no longer responds to obsolete TLS versions, and your app is running with defaults that try an older version of TLS.

Try adding this somewhere around the startup code of your app:

        ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

There's a fair chance, that this error happens, because the API server no longer responds to obsolete TLS versions, and your app is running with defaults that try an older version of TLS.

Try adding this somewhere around the startup code of your app:

        ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

This worked for me. Thanks :)