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.