* * *

Author Topic: [SOLVED] Ouath 2 with LinkedIn and TFPHTTPServer  (Read 631 times)

tudi_x

  • Full Member
  • ***
  • Posts: 208
Re: Ouath 2 with LinkedIn and TFPHTTPServer
« Reply #15 on: July 11, 2017, 05:27:22 pm »
with 127.0.0.1 i am not getting the missing protocol message!

rvk

  • Hero Member
  • *****
  • Posts: 2566
Re: Ouath 2 with LinkedIn and TFPHTTPServer
« Reply #16 on: July 11, 2017, 05:27:51 pm »
I take it you stripped out the "field name:code value" line?
Because I can see you get a code back but I don't see the corresponding field name line.

My result:
Code: [Select]
------
starting...
request URI: /?code=AQQ1fbiK5thDm1gzhFsAh0dy3Pc83s59T6am7Zi13-PnwLsvMzv_vFtq6Q03-5qVlLHzMF5CNgGhFT4CucWRjBhna9hBc9c9ogAHZMq-QOfkSadJ3sk&state=T1499793870
request URL: /?code=AQQ1fbiK5thDm1gzhFsAh0dy3Pc83s59T6am7Zi13-PnwLsvMzv_vFtq6Q03-5qVlLHzMF5CNgGhFT4CucWRjBhna9hBc9c9ogAHZMq-QOfkSadJ3sk&state=T1499793870
request Queryfields: code=AQQ1fbiK5thDm1gzhFsAh0dy3Pc83s59T6am7Zi13-PnwLsvMzv_vFtq6Q03-5qVlLHzMF5CNgGhFT4CucWRjBhna9hBc9c9ogAHZMq-QOfkSadJ3sk
state=T1499793870
http version: 1.1
protocol version: 1.1
server error: nil
field name:code value:AQQ1fbiK5thDm1gzhFsAh0dy3Pc83s59T6am7Zi13-PnwLsvMzv_vFtq6Q03-5qVlLHzMF5CNgGhFT4CucWRjBhna9hBc9c9ogAHZMq-QOfkSadJ3sk
field name:state value:T1499793870
stopping...
------
starting...
request URI: /favicon.ico
request URL: /favicon.ico
request Queryfields:
http version: 1.1
protocol version: 1.1
server error: nil
field name:code value:AQQ1fbiK5thDm1gzhFsAh0dy3Pc83s59T6am7Zi13-PnwLsvMzv_vFtq6Q03-5qVlLHzMF5CNgGhFT4CucWRjBhna9hBc9c9ogAHZMq-QOfkSadJ3sk
field name:state value:T1499793870
stopping...

You see for both request the field name code and state.
(You need to do the check for >0 of count otherwise your variable is overwritten.

Anyway... In both requests I see a http version 1.1 and protocol 1.1
So I'm not sure where the error comes from.


rvk

  • Hero Member
  • *****
  • Posts: 2566
Re: Ouath 2 with LinkedIn and TFPHTTPServer
« Reply #17 on: July 11, 2017, 05:28:49 pm »
with 127.0.0.1 i am not getting the missing protocol message!
Ah, Ok.
In that case it might be a "bug" in Firefox developer that the HTTP/1.1 is not correctly send with localhost.
Or maybe the first line is empty and the second is HTTP/1.1 while that HTTP/1.1 should always be the exact first line.

tudi_x

  • Full Member
  • ***
  • Posts: 208
Re: [SOLVED] Ouath 2 with LinkedIn and TFPHTTPServer
« Reply #18 on: July 11, 2017, 05:32:33 pm »
i am extracting the authorization code with the below:

Code: Pascal  [Select]
  1. procedure TForm1.HandleHTTPInfo;
  2. var
  3.   i: integer;
  4.  
  5. begin
  6.   for i:= Length(_HTTPRequestInfo) - 1 downto 0 do
  7.   begin
  8.     Memo1.Append('field name:' + _HTTPRequestInfo[i].FieldName + ' value:' + _HTTPRequestInfo[i].FieldValue);
  9.     if  _HTTPRequestInfo[i].FieldName = 'state' then begin
  10.       if _HTTPRequestInfo[i].FieldValue = _Salt then begin
  11.         if (i - 1) >= 0 then begin
  12.           if _HTTPRequestInfo[i-1].FieldName = 'code' then begin
  13.             _AuthorizeCode:=_HTTPRequestInfo[i-1].FieldValue;
  14.             Memo1.Append('authorize code:' + _AuthorizeCode);
  15.             break;
  16.           end;
  17.         end;
  18.       end;
  19.     end;
  20.   end;
  21. end;  
  22.  

rvk

  • Hero Member
  • *****
  • Posts: 2566
Re: [SOLVED] Ouath 2 with LinkedIn and TFPHTTPServer
« Reply #19 on: July 11, 2017, 05:39:48 pm »
i am extracting the authorization code with the below:
Yes, that should work.

B.T.W. you mentioned adding the openssl dll's to the directory.
using Lazarus 1.6.4 on Windows 7 64 bit
you would need libeay32.dll and ssleay32.dll in same directory as exe
But for just the HTTP server / authentication part you won't need these yet.
You only need them when doing https.
But my guess is that you will be doing the further communication via fphttp components for which you need https access.

First (and hardest) part is over  :D

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus