I received an "End of Life" email from RingCentral about my "password-based auth" method of getting a token will no longer supported as of next March. I have been using this method of getting a token for a few years, so I know the code I am using is working correctly. The app my users use is a Windows .exe, built using the Lazarus IDE and the programming language FreePascal and the component I use is the Indy HTTP component. There is no SDK involved. To test my POST call, I use Postman along side my .exe just to eliminate the possibility that one or the other is coded/configured wrong. I have set up my POST request in Postman as explained in these instructions and I also changed the code in my own FreePascal app the same way. In both the Postman POST and my own Windows .exe, I get the exact same error message shown here:
{
"error": "unauthorized_client",
"errors": [
{
"errorCode": "OAU-251",
"message": "Unauthorized for this grant type"
}
],
"error_description": "Unauthorized for this grant type"
}
When making my JWT I chose "All apps from your organization"
I downloaded my production creds for this RingCentral production app into a JSON file. Here it is with the private info hidden:
{
"username": "+<HIDDEN>",
"password": "<YOUR ACCOUNT PASSWORD>",
"extension": "201",
"clientId": "<HIDDEN>",
"clientSecret": "<HIDDEN>",
"server": "https://platform.ringcentral.com",
"jwt": {
"RubiDialerJWT": "<HIDDEN>"
}
}
As you can see, the JWT was associated with this app, as I requested.
Here are the screen shots from my Postman attempt:
postman_sets.pdf
Here is the code I'm using in Lazarus:
procedure TfrmDialRC.GetTokenRCJasonWebToken;
var
htp: TIdHTTP;
prms_stm: TStringStream; s: String;
tkn_ok: Boolean;
begin
try
htp := htpTkn;
s := 'grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer&assertion=' + GV.RingCentral.JWT;
prms_stm := TStringStream.Create(s);
if htp.Connected then
htp.Request.Connection := 'close';
htp.Request.Clear;
htp.Request.Accept := 'application/json';
htp.Request.ContentType := 'application/x-www-form-urlencoded';
htp.Request.Username := GV.RingCentral.ClientID;
htp.Request.Password := GV.RingCentral.ClientSecret;
htp.Request.BasicAuthentication := True;
htp.Post('https://platform.ringcentral.com/restapi/oauth/token', prms_stm);
finally
prms_stm.Free;
htp.Request.Connection := 'close';
end;
end;
Is there some other step that I have to take to make this work?
Thanks in advance for your help.