Not getting access token

Not getting access token

I am coding in C# .Net core 6. I have installed the SDK (ZOHOCRMSDK-2.1). I have this code in program.cs:

  1. var logger = new Logger.Builder().Build();

  2. UserSignature user = new UserSignature("user@email.xxx");

  3. Com.Zoho.Crm.API.Dc.DataCenter.Environment environment = USDataCenter.SANDBOX;

  4. Token token = new OAuthToken.Builder()
  5.     .ClientId("1234567890")
  6.     .ClientSecret("2345678901")
  7.     .RefreshToken("3456789012")
  8.     .Build();

  9. TokenStore tokenStore = new FileStore("C:\\TokenStore\\sdktoken.txt");

  10. tokenStore.SaveToken(user, token);

  11. SDKConfig config = new SDKConfig.Builder().AutoRefreshFields(false).PickListValidation(false).Build();

  12. new SDKInitializer.Builder()
  13.     .User(user)
  14.     .Environment(environment)
  15.     .Token(token)
  16.     .Store(tokenStore)
  17.     .SDKConfig(config)
  18.     //.ResourcePath(resourcePath)
  19.     .Logger(logger)
  20.     .Initialize();

I added a controller / call to retrieve all Modules (as a test)

  1.     [ApiController]
  2.     [Route("[controller]")]
  3.     public class ModulesController : ZohoBaseController
  4.     {
  5.         private HttpResponseMessage _response;
  6.         private string _rtnData = string.Empty;

  7.         private readonly JsonSerializerSettings _jsonSettings = new JsonSerializerSettings {
  8.             ContractResolver = new CamelCasePropertyNamesContractResolver(),
  9.             Formatting = Formatting.Indented
  10.         };

  11.         [HttpGet(Name = "ModuleList")]
  12.         public HttpResponseMessage List()
  13.         {
  14.             //Get instance of ModulesOperations Class
  15.             ModulesOperations moduleOperations = new ModulesOperations();
  16.             HeaderMap headerInstance = new HeaderMap();
  17.             DateTimeOffset ifModifiedSince = new DateTimeOffset(new DateTime(2020, 05, 15, 12, 0, 0, DateTimeKind.Local));
  18.             headerInstance.Add(ModulesOperations.GetModulesHeader.IF_MODIFIED_SINCE, ifModifiedSince);
  19. //Call GetModules method that takes headerInstance as parameters
  20.             APIResponse<ResponseHandler> response = moduleOperations.GetModules(headerInstance);


  21.             // Serialise the return data
  22.             _rtnData = JsonConvert.SerializeObject(response, _jsonSettings);

  23.             //_response = Request.CreateResponse(HttpStatusCode.OK);
  24.             _response = new HttpResponseMessage(HttpStatusCode.OK);

  25.             _response.Content = new StringContent(_rtnData, Encoding.UTF8, "application/json");
  26.             return _response;
  27.         }
  28.     }

But this fails with this at "moduleOperations.GetModules(headerInstance)":
  1. Com.Zoho.API.Exception.SDKException
  2.   HResult=0x80131500
  3.   Message=Input string was not in a correct format.
  4.   Source=ZOHOCRMSDK-2.1
  5.   StackTrace:
  6.    at Com.Zoho.Crm.API.Util.CommonAPIHandler.APICall[T](Type className, String encodeType)
  7.    at Com.Zoho.Crm.API.Modules.ModulesOperations.GetModules(HeaderMap headerInstance)
  8.    at KervPlatformZoho.Controllers.ModulesController.List() in C:\...\Controllers\ModulesController.cs:line 33
  9.    at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
  10.    at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()
  11.    at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
  12.    at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()

  13.   This exception was originally thrown at this call stack:
  14.     [External Code]

  15. Inner Exception 1:
  16. FormatException: Input string was not in a correct format.

I have a record in the TokenStore (file) but it is missing access_token, grant_token, expiry_time and redirect_url.

I created a "Self Client", generated a code and used Postman to "Generate Access Token and Refresh Token". I entered the Refresh Token in the code above.

So - what am I missing?