添加范围来使用的OAuth 1.0 DotNetOpenAuth授权请求 [英] Adding scopes to OAuth 1.0 authorization request with DotNetOpenAuth

查看:156
本文介绍了添加范围来使用的OAuth 1.0 DotNetOpenAuth授权请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何添加的范围以我authRequest?

 公共无效prepareAuthorizationRequest(URI authCallbakUrl)
{
    VAR消费=新WebConsumer(GoogleConsumerConsts.ServiceDescription,mConsumerTokenManager);    // 申请进入
    consumer.Channel.Send(消费prepareRequestUserAuthorization(authCallbakUrl,NULL,NULL));    抛出新NoRedirectToAuthPageException();
}


解决方案

范围是不是在OAuth的1.0,您正在使用此示例中定义的概念。要定义的访问请求的范围,你应该阅读你正在使用的服务供应商的文档,包括所需的额外的参数。假设服务提供商要你包括范围参数,您应与​​第二个参数传递,就像这样:

  VAR requestParameters的=新词典<字符串,字符串> {
    {范围,HTTP://有的/范围},
};
consumer.Channel.Send(消费prepareRequestUserAuthorization(authCallbackUrl,requestParameters的,NULL));

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();
}

解决方案

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));

这篇关于添加范围来使用的OAuth 1.0 DotNetOpenAuth授权请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆