Xero - beautiful accounting software

Xero Developer Help Center

Xero Developer Community

Community > API Authentication >

C# example of refreshing an OAuth2 token

Started by Tony Carter2 -   in API Authentication


I was wondering if you could help me with a sample code in c# to refresh a token. I need something like this:
// first I am trying to fetch a refresh token from a database (this part is clear)
string refreshToken = GetRefreshToken(clientId);
// after that refresh the token using refresh token (not sure what parameters are needed)
var xeroToken = await client.RefreshAccessTokenAsync(string refreshToken);
string accessToken = xeroToken.accessToken;
refreshToken = xeroToken.refreshToken;
// after that I am trying to save the new access and refresh tokens into the database
saveXeroToken(clientId, accessToken, refreshToken);

I tried looking up the API documentation, but could not find how to use client.RefreshAccessTokenAsync()