ICEMortgageTechnology / developerconnect-dotnet-bindings

43 stars 27 forks source link

Retrieving the Access Token #12

Open MikeN3 opened 6 years ago

MikeN3 commented 6 years ago

Hello,

I am having trouble in retrieving the access token. I have followed the step by step guide both on this github repo along with the ElliMae developer portal. As a side note there is a typo on step 2 in the repo page as the apiHost points to "https://api.elliemae.com.com" instead of "https://api.elliemae.com".

Here is my App.Config file.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="ElliApiConfig" type="Elli.Api.Base.ApiConfiguration, Elli.Api.Base" />
  </configSections>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
    </startup>
  <ElliApiConfig apiHost="https://api.elliemae.com" apiClientId="ClientId" clientSecret="ClientSecret" idpHost="idp.elliemae.com" redirectUrl="" />
</configuration>

Here is my Program.cs file

using Elli.Api.Base;
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                var credentials = new UserCredential
                {
                    Password = "Password",
                    IdentityType = IdentityType.Lender,
                    InstanceId = "InstanceId",
                    UserName = "Username"
                };
                var accessToken = AccessToken.GetAccessToken(credentials);
                Console.WriteLine(accessToken);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error when processing request: " + ex.Message);
            }

            Console.ReadKey();
        }
    }
}

When I run this I get the following error in the exception: "Error calling GenerateToken: The underlying connection was closed: An unexpected error occurred on a send." I am confused since this should be a pretty simple task to do. Maybe I'm missing something very obvious. Also nothing appears on fiddler when I do run this program.

Thank you!

dllewell commented 6 years ago

Mike, Try adding the code below before your var credentials line.

ServicePointManager.SecurityProtocol = ServicePointManager.SecurityProtocol | SecurityProtocolType.Tls12;

binbit commented 6 years ago

Have the same issue for AccessToken.GetAccessToken if use GenerateToken from TokenApi it works.

binbit commented 6 years ago

Sorry, was wrong configuration