1

Using DotNetOpenAuth, we've succesfully implemented asynchronous 2- and 3-legged authentication.

However, we are now facing a situation where we need to perform synchronous 2-legged authentication. At the moment the user presses a button to retrieve data, we need to sequentially 1) obtain a token and 2) perform the data request using this token. An asynchronous 2-legged authentication with callback would result in the retrieval failing the first time and -after the authentication is complete- succeeding when the user presses the button a second time.

In DotNetOpenAuth there is a WebServerClient, a consumer that seems to be able to retrieve an OAuth token based on a consumer Key and Secret, using a 2-legged OAuth step.

The question: Is it possible to await the result of this token retrieval?

We're looking for some code samples that explain this concept, because we cannot seem to find sample usages of the WebServerClient

4

1 回答 1

0

毕竟我们已经在 WebConsumer 类中找到了解决方案。使用同步 2-legged OAuth 步骤获取令牌的方法

OAuthGlobals.TokenManager = new InMemoryTokenManager(consumerKey, consumerSecret); 
WebConsumer consumer = new WebConsumer(OAuthGlobals.ServiceProviderDescription, OAuthGlobals.TokenManager); 
OAuthGlobals.AccessToken = consumer.RequestNewClientAccount();

执行RequestNewClientAccount()同步步骤。

当然,处理这个请求的处理程序需要能够处理它,所以我们需要针对这种情况进行调整。

于 2013-09-19T12:25:01.867 回答