AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

oAuth

Ein Thema von trax17 · begonnen am 14. Jul 2011 · letzter Beitrag vom 15. Jul 2011
Antwort Antwort
trax17

Registriert seit: 14. Jul 2011
2 Beiträge
 
#1

oAuth

  Alt 14. Jul 2011, 20:05
Ist hier bei irgend jemandem eine "gewisse" Erfahrung zu dem Thema vorhanden?
Ich versuche verzweifelt den Code von http://chuckbeasley.wordpress.com/20...th-for-delphi/ ans laufen zu bekommen.

Ich möchte gerne die Kombination DropBox / oAuth hinbekommen.

Es scheitert bei mir am "abholen" des Tokens auf:
https://api.dropbox.com/0/oauth/access_token
  Mit Zitat antworten Zitat
Benutzerbild von s.h.a.r.k
s.h.a.r.k

Registriert seit: 26. Mai 2004
3.159 Beiträge
 
#2

AW: oAuth

  Alt 14. Jul 2011, 21:31
Und was genau scheitert? Hast du schon Code geschrieben, der nicht funktioniert? Oder hast du Probleme beim Ansatz? Ein wenig mehr Infos wären da schon hilfreich
»Remember, the future maintainer is the person you should be writing code for, not the compiler.« (Nick Hodges)
  Mit Zitat antworten Zitat
trax17

Registriert seit: 14. Jul 2011
2 Beiträge
 
#3

AW: oAuth

  Alt 15. Jul 2011, 06:40
Anbei mein Code.
Ich bin mir auch unsicher, da in der .Net Anwendung http://sharpbox.codeplex.com/ die Authentifizierung nicht komplett über oAuth abläuft:
https://www.dropbox.com/developers/docs#token

Mein Projekt ist als ZIP File im Anhang.


Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdHTTP,
  StdCtrls, OleCtrls, SHDocVw;

type
  TForm1 = class(TForm)
    WebBrowser1: TWebBrowser;
    GroupBox1: TGroupBox;
    Label1: TLabel;
    edtAppKey: TEdit;
    Label2: TLabel;
    edtAppSecret: TEdit;
    Label3: TLabel;
    Label4: TLabel;
    edtUserName: TEdit;
    edtPassword: TEdit;
    btn1: TButton;
    btn2: TButton;
    procedure btn1Click(Sender: TObject);
    procedure btn2Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation


uses
OAuth;

{$R *.dfm}

var
ConsumerKey, ConsumerSecret, UserName, Password : String;
AccessTokenUrl, AuthorizationTokenUrl, RequestTokenUrl : String;

  IdHTTP1 : TIdHTTP;

  Consumer : TOAuthConsumer;
  ARequest : TOAuthRequest;
  Token : TOAuthToken;
  Response : String;
  HMAC : TOAuthSignatureMethod_HMAC_SHA1;
  TokenKey : String;
  TokenSecret : String;



procedure TForm1.btn1Click(Sender: TObject);
var
  Url : String;
begin

   AccessTokenUrl := 'http://api.dropbox.com/0/oauth/access_token';
   AuthorizationTokenUrl := 'http://www.dropbox.com/0/oauth/authorize';
   RequestTokenUrl := 'http://api.dropbox.com/0/oauth/request_token';

   ConsumerKey := edtAppKey.Text;
   ConsumerSecret := edtAppSecret.Text;
   UserName := edtUserName.Text;
   Password := edtPassword.Text;

   Consumer := TOAuthConsumer.Create(ConsumerKey, ConsumerSecret);
   HMAC := TOAuthSignatureMethod_HMAC_SHA1.Create;

   //Step 1 – Request request token (step A in diagram)

    IdHTTP1 := TidHTTP.create(nil);

    ARequest := TOAuthRequest.Create(RequestTokenUrl);
    ARequest := ARequest.FromConsumerAndToken(Consumer, nil, RequestTokenUrl);

    ARequest.Sign_Request(HMAC, Consumer, nil);

    Url := RequestTokenUrl + '?' + ARequest.GetString;

    Response := IdHTTP1.Get(Url);

    TokenSecret := Copy(Response, 20, 15);
    TokenKey := Copy(Response, 48, 63);


    Token := TOAuthToken.Create(TokenKey, TokenSecret);

    //Step 2 – Authorize (Step C in diagram)

    Url := AuthorizationTokenUrl;

    Url :=
    URL + '?' + 'oauth_token=' + TokenKey;

    WebBrowser1.Navigate(Url);

   end;




procedure TForm1.btn2Click(Sender: TObject);
var Url : String;
begin
    //Step 3 – Request access token (Step E in diagram)

    Url := '';
    Url := AccessTokenUrl;

    Consumer := nil;

    Consumer := TOAuthConsumer.Create(TokenKey, TokenSecret);

    ARequest.HTTPURL := Url;
    ARequest := ARequest.FromConsumerAndToken(Consumer, Token, URL);
    ARequest.Sign_Request(HMAC, Consumer, Token);

    Url := Url + '?' + ARequest.GetString;

    Response := idHTTP1.Get(Url);

    idhttp1.ResponseText;

    TokenSecret := Copy(Response, 20, 15);
    TokenKey := Copy(Response, 48, 63);

    Token := TOAuthToken.Create(TokenKey, TokenSecret);
end;

end.

Dazu verwende ich "OAuth for Delphi", zu finden unter: http://sourceforge.net/projects/oauthdelphi/
Angehängte Dateien
Dateityp: zip DropBox.zip (21,8 KB, 135x aufgerufen)
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 22:58 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz