Adding scopes to OAuth 1.0 authorization request with DotNetOpenAuth

ぐ巨炮叔叔 提交于 2019-12-12 01:28:56

问题


How do I add scopes to my authRequest?

public void PrepareAuthorizationRequest(Uri authCallbakUrl)
{
    var consumer = new WebConsumer(GoogleConsumerConsts.ServiceDescription, mConsumerTokenManager);

    // request access
    consumer.Channel.Send(consumer.PrepareRequestUserAuthorization(authCallbakUrl, null, null));

    throw new NoRedirectToAuthPageException();
}

回答1:


Scope isn't a defined concept in OAuth 1.0, which you're using in this sample. To define the scope of requested access, you should read the documentation of the service provider you're using and include the required additional parameters. Assuming the service provider wants you to include a scope parameter, you should pass it in with the second parameter, like so:

var requestParameters = new Dictionary<string, string> {
    { "scope", "http://some/scope" },
};
consumer.Channel.Send(consumer.PrepareRequestUserAuthorization(authCallbackUrl, requestParameters, null));


来源:https://stackoverflow.com/questions/9546780/adding-scopes-to-oauth-1-0-authorization-request-with-dotnetopenauth

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!