Skip to main content
Solved

Resource owner password flow

  • Feb 24, 2025 11:10 PM UTC
  • 9 replies
  • 170 views
  • Translate All

Hello,

I am using a restful api to get invoice as described by the documentation using Resource owner password flow. after generated a token I made a call to api to get invoice

Url + "Invoice?filter=ReferenceNbr eq 'XXXXXX'&$filter=ReferenceNbr eq 'XXXXXX'"

after 2 successful attempt to get invoice when I try to get invoice for the third time I get error

API Login Limit

I tried to logout after each request, but the logout request getting 204 no matter what I passed in the authorization. so not sure if logout is working with me.

 

using var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, configuration["SignoutUrl"]);
request.Headers.Add("Accept", "*/*");
string authInfo = configuration["UserName"] + ":" + configuration["Password"];
authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));
request.Headers.Add("Authorization", "Basic " + authInfo);

var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();

how to get unlimited calls for that user trying to login getting the token and make request.

Best answer by Dmitrii Naumov

​@swassouf do yo have ‘concurrent_access’ scope?

I’d recommend to remove this scope and try without it. That way you’ll reuse the existing API session and will not face the issue.

View original

9 replies

hdussa
Jr Varsity I
Forum|alt.badge.img+2
  • Jr Varsity I
  • Feb 25, 2025 3:41 AM UTC

Hello ​@swassouf ,

It could be a limit set for API connections. Please see below instructions and verify the limit.

 

Assuming, you are using  offline_access scope, I would try refreshing the token rather logging out after each request.

Lastly because of the security concerns, it is preferable to use other authorization flows such as Authorization Code Flow if possible.

 

Hope this helps!

Translate

  • Author
  • Freshman I
  • Feb 25, 2025 4:58 PM UTC

Hi 

Thank you Harish for your fast response.

I am not using a website I am using a worker windows service and I don’t have a Url to be redirected to. so can I use Authorization Code flow to get required token in windows service? 

Translate

hdussa
Jr Varsity I
Forum|alt.badge.img+2
  • Jr Varsity I
  • Feb 26, 2025 2:57 AM UTC

Hello ​@swassouf ,

I assumed you were using website. I have zero knowledge Acumatica API integration with worker services, sorry!. It seem to be you have no choice but stick to resource owner password flow.

I hope the article below will help you.

https://help.acumatica.com/Help?ScreenId=ShowWiki&pageid=822ddb44-b14f-481a-90c7-f15521e61702

Happy coding!

Translate

Dmitrii Naumov
Community Manager
Forum|alt.badge.img+7
  • Community Manager
  • Answer
  • Feb 26, 2025 3:55 PM UTC

​@swassouf do yo have ‘concurrent_access’ scope?

I’d recommend to remove this scope and try without it. That way you’ll reuse the existing API session and will not face the issue.

Translate

  • Author
  • Freshman I
  • Feb 26, 2025 4:08 PM UTC

​@Dmitrii Naumov  I removed the concurrent_access from scope I am just including api offline_access

in the third request I got  “API Login Limit” 

Should I cache the token and use it for multiple request till expire and then call  for another one. 

if I am using same token it works fine. 

Translate

Dmitrii Naumov
Community Manager
Forum|alt.badge.img+7

​@swassouf yes, you should use the same token until it expires. When it expires you can use the refresh token to get a new token.

Translate

  • Author
  • Freshman I
  • Feb 27, 2025 4:24 PM UTC

How to refactor this to new ERP?  CustomFields property not found and replaced with Custom

and fieldName, viewName are missing too (deprecated) 

Do you have an example to pass Custom property?

CustomFields = new AccumaticaApi.CustomField[]
 {
          new AccumaticaApi.CustomStringField
          {
                fieldName = "InvoiceNbr",
                viewName = "Document",
                Value = xxxxx
          },
     new AccumaticaApi.CustomStringField
     {
         fieldName = "PaymentMethodID",
         viewName = "CurrentDocument",
         Value =  xxxxx
     }

}

Translate

Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • Jun 17, 2025 9:02 PM UTC

Hi ​@swassouf were you able to find a solution? Thank you!

Translate

  • Author
  • Freshman I
  • Jun 17, 2025 9:14 PM UTC

​@Chris Hackett 

I am good thank you. It is now using Dictionary. 

Translate