Force.com-Toolkit-for-NET
Force.com-Toolkit-for-NET copied to clipboard
Handling refresh tokens
Based on #241, I am doing a wrapper to handle token expirations. For each operation I am doing something like:
try
{
return await _client.CreateAsync(record.SObjectType, record);
}
catch (ForceException e)
{
await RefreshTokenOrRethrowException(e);
return await _client.CreateAsync(record.SObjectType, record);
}
which is pretty verbose.
So my first question is: should we handle token expiration inside the ForceClient? I could work on a PR for this.
My next question is regarding bulk operations: for example RunJobAndPollAsync makes several API calls and each of these should handle a potential token expiration.
If we handle them in the ForceClient class, we could do it in the individual functions, like RunJobAsync and PollBatchAsync, but if not, what would be a good strategy to deal with this?
Thanks!