I'm trying to connect and get Access Token from eBay Sellers API.
I'm doing something wrong and I don't know what. I'm having RESTClient, RESTRequest, RESTResponse and button component on my form and I want to get access token on button click.
Here is my code:
procedure TForm5.btn1Click(Sender: TObject);
var
vClientId, vClientSecret : string;
vBase64,vBase: String;
vItem: TRESTRequestParameter;
vRuNames, vIspravno, str : string;
vOdgovor : string;
vContent, vContent1: string;
begin
vClientId:='jackjump-proba-SBX-15d7a0307-68d66d5a';
vClientSecret:=':SBX-5d7a03073f13-cb20-4a72-b71e-4e53';
vBase:=vClientId+':'+vClientSecret;
vBase64:='Basic '+TNetEncoding.Base64.Encode(vClientId+vClientSecret);
vIspravno:='Basic amFja2p1bXAtcHJvYmEtU0JYLTE1ZDdhMDMwNy02OGQ2NmQ1YTpTQlgtNWQ3YTAzMDczZjEzLWNiMjAtNGE3Mi1iNzFlLTRlNTM=';
vBase64 := StringReplace(vBase64, sLineBreak, '', [rfReplaceAll]);
vRuNames:='jack_jumping-jackjump-proba--tbccomu';
RESTClient1:=TRESTClient.Create('https://api.sandbox.ebay.com/');
RESTRequest1.Resource:='identity/v1/oauth2/token';
RESTRequest1.AddParameter('Content-Type', 'application/x-www-form-urlencoded', pkHTTPHEADER);
RESTRequest1.AddParameter('Authorization', vBase64, pkHTTPHEADER);
vContent :='grant_type=client_credentials&redirect_uri=jack_jumping-jackjump-proba--tbccomu&scope=https://api.ebay.com/oauth/api_scope';
RESTRequest1.Body.Add(vContent);
RESTRequest1.Execute;
end;
By clicking on the button I get/raise exception 500 internal server error.