Ejemplo n.º 1
0
 public Task<TokenResponse> GetToken(TokenRequest request)
 {
     try
     {
         var tokenRequest = ECashToApiConverter.ParseTokenRequest(request);
         var bimService = RestService.For<IBIMService>(Constants.CLIENT_URI);
         var tokenResponse = bimService.GenerateTokenAsync(tokenRequest).Result;
         var response = ApiToECashConverter.ParseToken(tokenResponse);
         return Task.FromResult(response);
     }
     catch (Exception e)
     {
         return Task.FromResult<TokenResponse>(new TokenResponse() { Result = CommonFunction.ParseException(e) });
     }
 }
Ejemplo n.º 2
0
        public static DTO.BIM.GenerateTokenRequest ParseTokenRequest(TokenRequest request)
        {
            if (request != null && request.Credentials !=null)
            {
                return new DTO.BIM.GenerateTokenRequest()
                {
                    client_id = Constants.CLIENT_ID,
                    client_secret = Constants.CLIENT_SECRET,
                    grant_type = Constants.GRANT_TYPE,
                    redirect_uri = Constants.REDIRECT_URI,
                    code = request.Credentials.AuthCode
                };
            }

            return null;
        }