Skip to content

Obtaining Invalid Client error. #577

@MarkLFT

Description

@MarkLFT

SDK you're using (please complete the following information):

  • Version 9.2

Describe the bug
With no change in my code, all tests relating to communicating with the account API fail with an invalid client error. I have confirmed the client ID is correct. I have tried an existing known good secret and a newly generated secret. Still the same.

The error is thrown in the RequestClientCredentialsTokenAsync() method call.

To Reproduce

var token = await _currentState.GetJwtToken();

if (token == null || token.ExpiresAtUtc <= DateTime.UtcNow.AddMinutes(5))
{
    XeroConfiguration xeroConfig = new()
    {
        ClientId = _options.Current.ClientId,
        ClientSecret = _options.Current.ClientSecret
    };
    var client = new XeroClient(xeroConfig);

    IXeroToken xeroToken = await client.RequestClientCredentialsTokenAsync();
    await _currentState.SetJwtToken(new JwtToken(xeroToken.AccessToken, xeroToken.RefreshToken, xeroToken.ExpiresAtUtc));
}

This is the code I use to obtain a token, code that has worked fine for months but now fails with an invalid client.

Expected behavior
A new access token to be issued to allow further interaction with the API.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions