Created
January 5, 2021 11:01
-
-
Save henzard/04a5d882cc0fd770cc3b93c32df4e598 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public XeroClient GetClient() | |
{ | |
var xeroConfig = new XeroConfiguration() | |
{ | |
ClientId = _xeroConfig.Value.XeroConnect.ClientId, | |
CallbackUri = new Uri(_xeroConfig.Value.XeroConnect.RedirectUri), | |
Scope = | |
"openid profile email offline_access files accounting.transactions accounting.contacts accounting.settings", | |
State = "WinFormsApp" | |
}; | |
return new XeroClient(xeroConfig); | |
} | |
private async Task<string> Refresh() | |
{ | |
var xeroClient = GetClient(); | |
var token = _xeroTokenStore.Find(p => p.TenantId == _xeroConfig.Value.XeroConnect.TenantId) | |
.FirstOrDefault(); | |
token = await xeroClient.RefreshAccessTokenAsync(token) as DbXeroToken; | |
_xeroTokenStore.Upsert(new DbXeroToken(_xeroConfig.Value.XeroConnect.TenantId, token)); | |
return token?.AccessToken; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment