1

OAuth2 による認証が必要な Windows ストア アプリを作成しようとしています。

推奨される方法は WebAuthenticationBroker です。

const string url = @"https://my.server.srv/mobile-auth/index.pl?"
                          + "client_id=CLIENTID"
                           + "&redirect_uri=https%3A%2F%2Fmy.server.srv
                           + "&response_type=code"

Uri startUri = new Uri(url);
Uri endUri = new Uri("https://my.server.srv");

WebAuthenticationResult webAuthenticationResult = await WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.None, startUri, endUri);
if (webAuthenticationResult.ResponseStatus == WebAuthenticationStatus.Success)
{
    string token = webAuthenticationResult.ResponseData;
}

しかし、トークンは空です。サーバーの応答があるはずです。

code=a-secret-code&expires_in=600&token_type=bearer

OAuth2 に準拠した GET で渡されます。

そのパラメータを取得する方法を知っていますか?

編集:解決しました。「https://localhost」をredirect_uri/endUriとして渡すと動き始めました。

4

1 に答える 1

0

Hammock などのライブラリを使用することをお勧めします。

通常、OAuth2 の場合、最初にリクエストを実行して、後続のすべてのリクエストに関連付けられるリクエスト トークンを取得します。次に、そのトークンをパラメータで使用して認証リクエストを実行すると、アクションを実行できるレスポンス オブジェクトが返されます。

Flickr には、OAuth プロセスがどのように機能するかについて (写真付きで) 最もよくまとめられた説明があります - http://www.flickr.com/services/api/auth.oauth.html

幸運を

于 2012-10-31T06:12:25.027 に答える