对于大多数情况,OAuth 2.0和OpenID Connect授权端点的GET请求需要具有许多查询字符串参数。

虽然您可以使用任何方法创建带参数的URL来创建正确的字符串,但RequestUrl类是完成此任务的简单帮助程序。

特别是,您可以使用CreateAuthorizeUrl扩展方法为授权端点创建URL - 它支持最常用的参数:

/// <summary>
/// Creates an authorize URL.
/// </summary>
/// <param name="request">The request.</param>
/// <param name="clientId">The client identifier.</param>
/// <param name="responseType">The response type.</param>
/// <param name="scope">The scope.</param>
/// <param name="redirectUri">The redirect URI.</param>
/// <param name="state">The state.</param>
/// <param name="nonce">The nonce.</param>
/// <param name="loginHint">The login hint.</param>
/// <param name="acrValues">The acr values.</param>
/// <param name="prompt">The prompt.</param>
/// <param name="responseMode">The response mode.</param>
/// <param name="codeChallenge">The code challenge.</param>
/// <param name="codeChallengeMethod">The code challenge method.</param>
/// <param name="display">The display option.</param>
/// <param name="maxAge">The max age.</param>
/// <param name="uiLocales">The ui locales.</param>
/// <param name="idTokenHint">The id_token hint.</param>
/// <param name="extra">Extra parameters.</param>
/// <returns></returns>
public static string CreateAuthorizeUrl(this RequestUrl request,
string clientId,
string responseType,
string scope = null,
string redirectUri = null,
string state = null,
string nonce = null,
string loginHint = null,
string acrValues = null,
string prompt = null,
string responseMode = null,
string codeChallenge = null,
string codeChallengeMethod = null,
string display = null,
int? maxAge = null,
string uiLocales = null,
string idTokenHint = null,
object extra = null)
{ ... }

例:

var ru = new RequestUrl("https://demo.identityserver.io/connect/authorize");

var url = ru.CreateAuthorizeUrl(
clientId: "client",
responseType: "implicit",
redirectUri: "https://app.com/callback",
nonce: "xyz",
scope: "openid");

注意

该extra参数可以是一个串字典或任意其它具有属性的类型。在这两种情况下,值都将序列化为键/值。

github地址

第2章 授权端点(Authorize Endpoint) - IdentityModel 中文文档(v1.0.0)的更多相关文章

  1. 第4章 令牌端点(Token Endpoint) - IdentityModel 中文文档(v1.0.0)

    令牌端点的客户端库(OAuth 2.0和OpenID Connect)作为HttpClient一组扩展方法提供.这允许HttpClient以您喜欢的方式创建和管理生命周期- 例如静态或通过像Micro ...

  2. 第7章 UserInfo端点(UserInfo Endpoint) - IdentityModel 中文文档(v1.0.0)

    OpenID Connect UserInfo端点的客户端库是作为扩展HttpClient方法提供的. 以下代码将访问令牌发送到UserInfo端点: var client = new HttpCli ...

  3. 第1章 发现端点(Discovery Endpoint) - IdentityModel 中文文档(v1.0.0)

    OpenID Connect发现端点的客户端库作为httpclient的扩展方法提供.该GetDiscoveryDocumentAsync方法返回一个DiscoveryResponse对象,该对象具有 ...

  4. 第9章 设备授权端点(Device Authorization Endpoint) - IdentityModel 中文文档(v1.0.0)

    OAuth 2.0设备流设备授权的客户端库是作为HttpClient扩展方法提供的. 以下代码发送设备授权请求: var client = new HttpClient(); var response ...

  5. 第6章 令牌撤销端点(Token Revocation Endpoint) - IdentityModel 中文文档(v1.0.0)

    OAuth 2.0令牌撤销的客户端库是作为扩展方法提供的HttpClient. 以下代码撤消撤销端点处的访问令牌令牌: var client = new HttpClient(); var resul ...

  6. 第5章 令牌自省端点(Token Introspection Endpoint) - IdentityModel 中文文档(v1.0.0)

    OAuth 2.0令牌自省的客户端库是作为HttpClient扩展方法提供的. 以下代码将引用令牌发送到内省端点: var client = new HttpClient(); var respons ...

  7. 第3章 结束会话端点(EndSession Point) - IdentityModel 中文文档(v1.0.0)

    该RequestUrl类可用于构造URL发送到OpenID Connect EndSession endpoint. 该CreateEndSessionUrl扩展方法支持最常用的参数: /// < ...

  8. IdentityModel 中文文档(v1.0.0) 目录

    欢迎使用IdentityModel文档! 第一部分 协议客户端库 第1章 发现端点(Discovery Endpoint) 第2章 授权端点(Authorize Endpoint) 第3章 结束会话端 ...

  9. 第47章 授权端点(Authorize Endpoint) - Identity Server 4 中文文档(v1.0.0)

    授权端点可用于通过浏览器请求令牌或授权码.此过程通常涉及最终用户的身份验证和可选的同意. 注意 IdentityServer支持OpenID Connect和OAuth 2.0授权请求参数的子集.有关 ...

随机推荐

  1. Mac--Homebrew简介及安装

    Homebrew官网:https://brew.sh/index_zh-cn.html 参考:http://www.jianshu.com/p/d229ac7fe77d 关于Homebrew Mac ...

  2. 最值得收藏的java技术博客(Java篇)

    第一个:java_my_life 作者介绍:找不到原作者信息.大概做了翻阅全部是2012年的博客. 博客主要内容:主要内容是关于Java设计模式的一些讲解和学习笔记,在相信对学习设计模式的同学帮助很大 ...

  3. python 3 中的raw_input 报错

    raw_input() was renamed to input()

  4. VM虚拟机下安装liunx系统

    1.首先打开VMware看到如图所示,然后点击创建虚拟机,选择典型然后下一步 2.选择我稍后安装操作系统然后下一步,选择Linux系统然后下一步.给虚拟机起一个名字,和选择把虚拟机安装在那个位置.然后 ...

  5. 12. thymeleaf中资源相对路径的解决

    把博客部署到tomcat上后才发现因之前资源和链接的地址都是使用的相对路径,这样一来在tomcat上就各种找不到资源.从网上看了几种解决方式都挺麻烦的,且不是适配的,所以我根据thymeleaf的规则 ...

  6. Python2 与 Python3 的编码对比

    在 Python 中,不论是 Python2 还是 Python3 中,总体上说,字符都只有两大类: 通用的 Unicode 字符: (unicode 被编码后的)某种编码类型的字符,比如 UTF-8 ...

  7. 新浪微博注册(elenium Python 自动化)

    from selenium import webdriverfrom selenium.webdriver.common.keys import Keysfrom time import sleep ...

  8. Eureka-服务注册与发现组件

    一.Eureka是Netflix开发的服务组件 本身是一个基于REST的服务,Spring Cloud将它集成在其子项目spring-cloud-netflix中,以实现Spring cloud的服务 ...

  9. Python简介之输入和输出

    输出 输入 输出 用print()在括号中加上字符串就可以向屏幕上输出指定的文字.比如输出'hello,world!',用代码实现如下:print('hello world!'). print()函数 ...

  10. 51nod 1135 原根 就是原根...

    %%% dalao Orz ,筛素数到sqrt(n),分解ϕ(p),依次枚举判断就好了 #include<cstdio> #include<cstring> #include& ...