ICEMortgageTechnology / developerconnect-dotnet-bindings

43 stars 27 forks source link

Unable to get token under web environment #18

Closed rostami79 closed 6 years ago

rostami79 commented 6 years ago

I am getting Error Retrieving access token in web application I revised the application to work on https on my localhost in IIS Express

I am able to get the authorization code

but getting the following error in ResponseHandler.aspx.cs when I am trying to get access token

[ApiException: Error calling GenerateToken: {"error_description":"unable to parse Authorization header java.lang.IllegalArgumentException: URLDecoder: Illegal hex characters in escape (%) pattern - For input string: \"ss\"","error":"invalid_client"} ] Elli.Api.OAuth.Api.TokenApi.GenerateTokenWithHttpInfo(String grantType, String username, String password, String scope, String redirectUri, String code, String session) +1166 Elli.Api.Base.AccessToken.GetAccessToken(String authCode, String redirectUrl, String apiClientId, String clientSecret) +209 Ellie.Api.Examples.Token.AuthCode.ResponseHandler.Page_Load(Object sender, EventArgs e) in C:\Users\majid.rostami\Downloads\developerconnect-dotnet-bindings-master\developerconnect-dotnet-bindings-master\SampleClients\OAuth\Ellie.Api.Examples.Token.AuthCode\ResponseHandler.aspx.cs:53 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51 System.Web.UI.Control.OnLoad(EventArgs e) +95 System.Web.UI.Control.LoadRecursive() +59 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +678

Here is my Web.config

<?xml version="1.0"?>

rostami79 commented 6 years ago

Actually I know what needs to be changed in responsehandeler.aspx.cs

modify access token Generation code to var accessToken = AccessToken.GetAccessToken(code, "https://localhost:44321/ResponseHandler.aspx", "clientid", System.Uri.EscapeUriString("clientSecret"));

(Replace the client secret and ID to our credentials )