RingCentral.Platform.Refresh C# (CSharp) Method

Refresh() public method

Refreshes expired Access token during valid lifetime of Refresh Token
public Refresh ( ) : ApiResponse
return RingCentral.Http.ApiResponse
        public ApiResponse Refresh()
        {
            if (!Auth.IsRefreshTokenValid()) throw new Exception("Refresh Token has Expired");

            var body = new Dictionary<string, string>
                       {
                           {"grant_type", "refresh_token"},
                           {"refresh_token", Auth.RefreshToken},
                           {"access_token_ttl", AccessTokenTtl},
                           {"refresh_token_ttl", Auth.Remember ? RefreshTokenTtlRemember : RefreshTokenTtl}
                       };

            var request = new Request(TokenEndpoint, body);
            var result = AuthCall(request);

            Auth.SetData(result.Json);

            _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Auth.AccessToken);

            return result;
        }