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

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

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

  1. /// <summary>
  2. /// Creates an authorize URL.
  3. /// </summary>
  4. /// <param name="request">The request.</param>
  5. /// <param name="clientId">The client identifier.</param>
  6. /// <param name="responseType">The response type.</param>
  7. /// <param name="scope">The scope.</param>
  8. /// <param name="redirectUri">The redirect URI.</param>
  9. /// <param name="state">The state.</param>
  10. /// <param name="nonce">The nonce.</param>
  11. /// <param name="loginHint">The login hint.</param>
  12. /// <param name="acrValues">The acr values.</param>
  13. /// <param name="prompt">The prompt.</param>
  14. /// <param name="responseMode">The response mode.</param>
  15. /// <param name="codeChallenge">The code challenge.</param>
  16. /// <param name="codeChallengeMethod">The code challenge method.</param>
  17. /// <param name="display">The display option.</param>
  18. /// <param name="maxAge">The max age.</param>
  19. /// <param name="uiLocales">The ui locales.</param>
  20. /// <param name="idTokenHint">The id_token hint.</param>
  21. /// <param name="extra">Extra parameters.</param>
  22. /// <returns></returns>
  23. public static string CreateAuthorizeUrl(this RequestUrl request,
  24. string clientId,
  25. string responseType,
  26. string scope = null,
  27. string redirectUri = null,
  28. string state = null,
  29. string nonce = null,
  30. string loginHint = null,
  31. string acrValues = null,
  32. string prompt = null,
  33. string responseMode = null,
  34. string codeChallenge = null,
  35. string codeChallengeMethod = null,
  36. string display = null,
  37. int? maxAge = null,
  38. string uiLocales = null,
  39. string idTokenHint = null,
  40. object extra = null)
  41. { ... }

例:

  1. var ru = new RequestUrl("https://demo.identityserver.io/connect/authorize");
  2. var url = ru.CreateAuthorizeUrl(
  3. clientId: "client",
  4. responseType: "implicit",
  5. redirectUri: "https://app.com/callback",
  6. nonce: "xyz",
  7. 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. Java基础:Java虚拟机(JVM)

    当我们第一次学习Java时这些原理上的东西就会被提到,但是很少有真正去学习.今天开始从头过一遍Java,打算从JVM开始. 1. JVM是什么 2. JRE和JDK 3. JVM结构 3.1. 程序计 ...

  2. 用bootstrap 分页插件问题

    如果页面加载js 一定要记得引入分页的东西 ,不然不会有数据, <script src="${path}/js/bootstrap-paginator.min.js"> ...

  3. windows下virtualenv中安装MySQL-python

    先在正常的环境下安装 MySQL-python-1.2.3.win-amd64-py2.7.exe (用everything搜索一下就出来) 然后到 C:\Python27\Lib\site-pack ...

  4. Python3 urllib.request库的基本使用

    Python3 urllib.request库的基本使用 所谓网页抓取,就是把URL地址中指定的网络资源从网络流中读取出来,保存到本地. 在Python中有很多库可以用来抓取网页,我们先学习urlli ...

  5. 由ping所引发的思考~

    今天看了掘金一片关于ping原理的文章,https://juejin.im/entry/5af8d5e651882565bd25581c?utm_source=gold_browser_extensi ...

  6. Tornado day1

    Tornado 之路由配置 首先导入模块,使用Application方法中可配置多个路由,格式必须为列表中是元组 元组的第一个是配置的url,第二个参数时自定义的类(继承自RequestHandler ...

  7. [CVPR 2017] Semantic Autoencoder for Zero-Shot Learning论文笔记

    http://openaccess.thecvf.com/content_cvpr_2017/papers/Kodirov_Semantic_Autoencoder_for_CVPR_2017_pap ...

  8. Springboot+Atomikos+Jpa+Mysql实现JTA分布式事务

    1 前言 之前整理了一个spring+jotm实现的分布式事务实现,但是听说spring3.X后不再支持jotm了,jotm也有好几年没更新了,所以今天整理springboot+Atomikos+jp ...

  9. 3.python元类编程

     1.1.propety动态属性 在面向对象编程中,我们一般把名词性的东西映射成属性,动词性的东西映射成方法.在python中他们对应的分别是属性self.xxx和类方法.但有时我们需要的属性需要根据 ...

  10. Oracle-07:别名,去重,子查询

    ------------吾亦无他,唯手熟尔,谦卑若愚,好学若饥------------- 依旧提供数据库脚本供操作 create table DEPT ( deptno ) not null, dna ...