[fpc-pascal] Just a question about OAuth 2.0 implementation

silvioprog silvioprog at gmail.com
Mon Apr 14 15:02:24 CEST 2014


2014-04-14 9:49 GMT-03:00 Michael Van Canneyt <michael at freepascal.org>:
>
>  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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20140414/2135f24f/attachment.html>


More information about the fpc-pascal mailing list