Jump to content
ZRomik

Error when post request

Recommended Posts

Hello!

I need to send post request on some site. And when I try  to execute request I get an error: "SSL requires a context object". How I can resolve this issuue?

Share this post


Link to post

You need to make your application SSL aware to use https, and that means using an SslContext, at least for older components.

 

I suggest you look at the new  OverbyteIcsHttpRestTst sample that uses the new OverbyteIcsSslHttpRest component, this hides the complexity of the SslContext from the application.

 

Angus

Share this post


Link to post

So. I trying to use TSslHttpCli instead of THttpCli, but nothing happing. Error still encounter when I post request to server.

Share this post


Link to post

OK. I'm watched in "OverbyteIcsHttpRestTst" and try to reproduce these code. But  always get message: "Failed to Generate App Token

App Authorization Code: blah-blah-blah". Where I can see what I'm doing wrong?

My code:

const
  sAuthURL            = 'https://login.eveonline.com/v2/oauth/authorize/';
  sRedirectURI        = 'http://localhost:5561/';
    sSecretKey        = '...';
 sTokenURL            = 'https://login.eveonline.com/oauth/token';
    sClientID         = '...';
    sScopeList        = 'esi-location.read_location.v1';
    sLocalAddr        = '127.0.0.1';
    sLocalPort        = '5561';
	sTokenURL     = 'https://login.eveonline.com/oauth/token';


procedure TForm1.imgLoginClick(Sender: TObject);
var
  url: string;
  sb: TStringBuilder;
  code: string;
begin
  mem1.Lines.Clear;
  SetupOAuth;
  if rest.StartAuthorization then
  begin
    mem1.Lines.Add('Waiting for authorization token...');
  end
else
  begin
    mem1.Lines.Add('Error while get authorization token: ' + rest.LastError);
  end;
end;

procedure TForm1.SetupOAuth;
begin
  rest.DebugLevel    := DebugSsl;
  rest.ProtoType     := OAuthv2;
  rest.AuthType      := OAuthTypeWeb;
  rest.AppUrl        := sAuthURL;
  rest.ClientId      := Trim(sClientID);
  rest.RedirectUrl   := Trim(sRedirectURI);
  rest.ClientSecret  := Trim(sSecretKey);
  rest.RedirectUrl   := Trim(sRedirectURI);
  rest.Scope         := sScopeList;
  rest.OAOptions     := [];
  rest.RefreshAuto   := True;
  rest.WebSrvIP      := sLocalAddr;
  rest.WebSrvPort    := sLocalPort;
  rest.TokenUrl      := sTokenURL;
end;

When I Set this parameters in demo all ok, but not work in my app

Edited by ZRomik

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×