Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2014-04

Just a question about OAuth 2.0 implementation

12 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

silvioprog

Hello,

Just a question, anyone here has implemented some code for OAuth 2.0? (FPC or Delphi)

I implemented with 1.0 in my new TDropbox class, but now I'm trying to implement it with 2.0, because I'm needing to make an automatic authorization in a server side app.

So, if you prefer no need to show me code, I'm just wondering if anyone has tried and already succeeded.

Thank you!

Silvio Clécio My public projects - github.com/silvioprog
Michael Van Canneyt
to silvioprog
silvioprog wrote 7 lines
Hello, Just a question, anyone here has implemented some code for OAuth 2.0? (FPC or Delphi) I implemented with 1.0 in my new TDropbox class, but now I'm trying to implement it with 2.0, because I'm needing to make an automatic authorization in a server side app. So, if you prefer no need to show me code, I'm just wondering if anyone has tried and already succeeded.

It is on my agenda. I was planning to add the OAuth 1.0 implementation of Reinier to fcl-web, then look at OAuth 2.0. I will be needing it myself.

Michael.

silvioprog
to Michael Van Canneyt

2014-04-14 9:49 GMT-03:00 Michael Van Canneyt :

Show quoted text 20 lines
On Mon, 14 Apr 2014, silvioprog wrote: > Hello, > Just a question, anyone here has implemented some code for OAuth 2.0? > (FPC or Delphi) > > I implemented with 1.0 in my new TDropbox class, but now I'm trying to > implement it with 2.0, because I'm needing to make an > automatic authorization in a server side app. > > So, if you prefer no need to show me code, I'm just wondering if anyone > has tried and already succeeded. > It is on my agenda. I was planning to add the OAuth 1.0 implementation of Reinier to fcl-web, then look at OAuth 2.0. I will be needing it myself. Michael.

Very nice. For 1.0 was easy, because I found a base code in PHP:

class function TDropboxOAuthUtil.GenerateAuthorizationContent(
  const AAppKey: string): string;
begin
  Result :=
    'oauth_consumer_key=' + AAppKey +
    '&oauth_nonce=' + GenerateNonce +
    '&oauth_signature_method=HMAC-SHA1' +
    '&oauth_timestamp=' + GenerateTimeStamp +
    '&oauth_version=1.0';
end;
class function TDropboxOAuthUtil.GenerateAuthorizationUrl(const AAppKey,
  AAppSecret: string): string;
var
  VSignature: string;
begin
  Result := GenerateAuthorizationContent(AAppKey);
  VSignature := 'POST&' + EncodeUrl(API_URL + '/oauth/request_token') + '&'
+
    EncodeUrl(Result);
  Result := API_URL + '/oauth/request_token?' + Result;
  VSignature := EncodeBase64(HMAC_SHA1(VSignature, AAppSecret + '&'));
  Result := Result + '&oauth_signature=' + EncodeUrl(VSignature);
end;

Now I'm trying with 2.0, if it work, I'll send you all my drafts.

Silvio Clécio My public projects - github.com/silvioprog
Reinier Olislagers
to silvioprog
silvioprog wrote 5 lines
2014-04-14 9:49 GMT-03:00 Michael Van Canneyt < >: On Mon, 14 Apr 2014, silvioprog wrote:

<snip>

Very nice. For 1.0 was easy, because I found a base code in PHP:

Or.... in .... cough... open source... OBJECT PASCAL, including test clients for not one but... count'em... 2 different services... console mode and even a GUI client for twitter?
https://bitbucket.org/reiniero/fpctwit

Code reuse? We've heard of it. It happens to other people...

I'll go sit in my chair and sulk now.... ;)

silvioprog
to Reinier Olislagers

2014-04-14 10:20 GMT-03:00 Reinier Olislagers :

Show quoted text 16 lines
On 14/04/2014 15:02, silvioprog wrote: > 2014-04-14 9:49 GMT-03:00 Michael Van Canneyt > < > >: > > On Mon, 14 Apr 2014, silvioprog wrote: <snip> > Very nice. For 1.0 was easy, because I found a base code in PHP: Or.... in .... cough... open source... OBJECT PASCAL, including test clients for not one but... count'em... 2 different services... console mode and even a GUI client for twitter? https://bitbucket.org/reiniero/fpctwit Code reuse? We've heard of it. It happens to other people... I'll go sit in my chair and sulk now.... ;)

Hahaha... :D

Now I downloaded and saw your implementation, and I think it very very fine! It deserves to go to Free Pascal.

Sorry for my carelessness hehe... I had done it based in PHP code because I did not saw something written in Free Pascal. :/ I found some code in Delphi, but could not make them work.

Now I'm finding any code implementing 2.0. I'm almost getting to do, my problem now is just a 400 error that I am trying to solve.

Free Pascal needs of OAuth classes for server too. :)

Silvio Clécio My public projects - github.com/silvioprog
Dariusz Mazur
to silvioprog: Just a question, anyone here has implemented some code for OAuth 2.0? (FPC or Delphi) I…
silvioprog wrote
Hello, Just a question, anyone here has implemented some code for OAuth 2.0? (FPC or Delphi)

I does one.
If You interested I public it on github.

Darek

Show quoted text 17 lines
I implemented with 1.0 in my new TDropbox class, but now I'm trying to implement it with 2.0, because I'm needing to make an automatic authorization in a server side app. So, if you prefer no need to show me code, I'm just wondering if anyone has tried and already succeeded. Thank you! -- Silvio Clécio My public projects - github.com/silvioprog <http://github.com/silvioprog> _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
silvioprog
to silvioprog: Just a question, anyone here has implemented some code for OAuth 2.0? (FPC or Delphi) I…

2014-04-14 9:39 GMT-03:00 silvioprog :

Show quoted text 14 lines
Hello, Just a question, anyone here has implemented some code for OAuth 2.0? (FPC or Delphi) I implemented with 1.0 in my new TDropbox class, but now I'm trying to implement it with 2.0, because I'm needing to make an automatic authorization in a server side app. So, if you prefer no need to show me code, I'm just wondering if anyone has tried and already succeeded. Thank you!

First draft working fine: https://duallsistemas.com.br/cgi1.bf

Sources: https://www.dropbox.com/s/dxyqe2ds7bjron7/web.tar.gz

Based on: https://github.com/smarx/othw/blob/master/PHP/index.php

ps. OAuth 2 the "Hard Way":
https://www.dropbox.com/developers/blog/52/dropbox-core-api-and-oauth-2-the-hard-way

Silvio Clécio My public projects - github.com/silvioprog