Skip to main content

Hi!

I am currently modifying one of our applications from password from to JWT. This application uses the Java SDK.

It works but I keep reading about not calling the /auth endpoint too frequently which I assumed transposes into calling authorize() on the rest client with the JWT.

Did I understood that right or are we talking about something else?

As a test I let my application call authorize() more than the documented limit of 5 times and it did not seem to cause any problem so maybe I am misunderstanding something and the limit of 5 times is not for that authorize() call...

Once I call authorize() do I have to do anything to reauthorize the rest client again? The application could stay up for months at a time.

I just want to make sure I call it just the right amount of time, not too frequently but not to the point the app will crash because I have not called it when I should have.

Our application is based on the example that were provided many years ago, using password flow it was calling authorize() for every call...

That being said, there were rarely more than one or two calls per minutes in normal circumstances, this might change...

Thank you and have a nice day!

Nick





Consider these examples.

Will hit the /authorize API rate limit

RestClient restClient = new RestClient("RC_CLIENT_ID", "RC_CLIENT_SECRET", "RC_SERVER_URL");

public void start_sending_sms(){
for (var i=0; i<10; i++){
send_sms("0123456789")
}
}

public void send_sms(fromNumber){
restClient.authorize("RC_JWT");
CreateSMSMessage requestBody = new CreateSMSMessage();
requestBody.from = new MessageStoreCallerInfoRequest().phoneNumber(fromNumber);
requestBody.to = new MessageStoreCallerInfoRequest[] {
new MessageStoreCallerInfoRequest().phoneNumber("RECIPIENT-NUMBER")
};
requestBody.text = "Hello World";

var resp = restClient.restapi().account().extension().sms().post(requestBody);
System.out.println("SMS sent. Message id: " + resp.id.toString());
}

Correct

RestClient restClient = new RestClient("RC_CLIENT_ID", "RC_CLIENT_SECRET", "RC_SERVER_URL");

public void start_sending_sms(){
restClient.authorize("RC_JWT");
for (var i=0; i<10; i++){
send_sms("0123456789")
}
}

public void send_sms(fromNumber){
CreateSMSMessage requestBody = new CreateSMSMessage();
requestBody.from = new MessageStoreCallerInfoRequest().phoneNumber(fromNumber);
requestBody.to = new MessageStoreCallerInfoRequest[] {
new MessageStoreCallerInfoRequest().phoneNumber("RECIPIENT-NUMBER")
};
requestBody.text = "Hello World";

var resp = restClient.restapi().account().extension().sms().post(requestBody);
System.out.println("SMS sent. Message id: " + resp.id.toString());
}

Hi!

This is what I was planning to do....

That said, I must have misread as I thought auth was limited to 5, not 10...

The way our app currently work I would currently call auth twice in a minute if I move the authorize out of the loop.

It has two different threads, one that send faxes which check for work each minute and one that check the status of the sent faxes which runs a lot less frequently (it wakes up every 5 minutes but only start checking the status of sent faxes after 8 minutes or so if I am not mistaken). Both (current) threads would need to call authorize()...

I had read something which suggested using you Java SDK meant that one did not have to deal with token expiries and the like, I guess they were mistaken.

Thank you very much and have a nice day!

Nick


Reply