obautista
obautista

Reputation: 3773

InvalidTokenException was unhandled by user code - "Unauthorized"

This is my code:

string accessToken = "##";

string accessTokenSecret = "##"; string consumerKey = "##"; string consumerSecret = "##"; string appToken = "##"; string realmId = "##"; //company id in quickbooks online

OAuthRequestValidator oauthValidator = new OAuthRequestValidator(accessToken, accessTokenSecret, consumerKey, consumerSecret);
ServiceContext context = new ServiceContext(oauthValidator, appToken, realmId, IntuitServicesType.QBO);

I am receiving: InvalidTokenException was unhandled by user code - {"Unauthorized"} in the creating the new ServiceContext line. Not sure what the problem is.

Thanks for any help provided.

Upvotes: 0

Views: 386

Answers (1)

Keith Palmer Jr.
Keith Palmer Jr.

Reputation: 27952

This error message:

InvalidTokenException was unhandled by user code - {"Unauthorized"}

Occurs when the OAuth tokens you're using are no longer valid.

I would double-check that:

  • You're using a valid set of OAuth tokens that you got from Intuit
  • The tokens are not expired (the Developer Playground tokens are very short lived, longer-lived 6-month tokens are available if you set up your own actual OAuth endpoint)

Here is Intuit's documentation for setting up your own OAuth endpoint:

Upvotes: 2

Related Questions