我正在尝试创建一个需要通过 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
传入 GET,它符合 OAuth2。
请问您知道如何获取这些参数吗?
编辑:已解决。它在将“https://localhost”作为redirect_uri / endUri 传递后开始工作。