Forum Discussion

EvgenyT's avatar
EvgenyT
Member
5 years ago

Oauth2.0 Access token user identifier

Hi guys,

 

We've implemented the Oauth2.0 authorization workflow using latest version (2020.202.0) of MYOB AccountRight API for C#.

 

We need to know MYOB user identifier who has been authorized. Due to MYOB documentation we can obtain it while exchange code for access token as example JSON looks like: 

{
    "access_token": "xxx",
    "token_type": "bearer",
    "expires_in": "1200",
    "refresh_token": "",
    "scope": "CompanyFile",
    "user": {
        "uid": "28_[TRUNCATED_FOR_READABILITY]_5c",
        "username": ""
    }
}

 

So we make call to API this way:

 

 

var handler = new OAuthRequestHandler(MyobSettings.DefaultApiConfiguration);
var request = WebRequest.CreateHttp(MyobSettings.Default.Endpoints.AccessTokenUrl);
var response = await handler.GetOAuthTokensAsync(request, "code");

HttpStatusCode status = response.Item1;
OAuthTokens token = response.Item2;

 

 

The problem is OAuthTokens class doesn't contain property "User". How can we get the currently authorized user identifier ? Probably use some other method that will get the user info ?

 

Thanks in advance,

Evgeny.

Looking for something else?

Search the Community Forum for answers or find your topic and get the conversation started!

Community home

Level up your skills using MYOB software.

 

Find help guides and technical solutions for all MYOB products here

Explore video tutorials for our software at the MYOB Academy here

 

Dig into MYOB Academy for free courses, learning paths and live events to help build your business with MYOB.