Identity Server 4 原理和实战(完结)_Resource Owner Password Credentials 授权实例

Identity Server 4 原理和实战(完结)_Resource Owner Password Credentials 授权实例
今天要讲的
Identity Server 4 原理和实战(完结)_Resource Owner Password Credentials 授权实例

Identity Server 4 原理和实战(完结)_Resource Owner Password Credentials 授权实例

Identity Server 4 原理和实战(完结)_Resource Owner Password Credentials 授权实例

Identity Server 4 原理和实战(完结)_Resource Owner Password Credentials 授权实例

用fiddler来监听,昨天的客户端的请求
这是一个post的请求
Identity Server 4 原理和实战(完结)_Resource Owner Password Credentials 授权实例
Identity Server 4 原理和实战(完结)_Resource Owner Password Credentials 授权实例
这是响应的数据

Identity Server 4 原理和实战(完结)_Resource Owner Password Credentials 授权实例

Expores_in超时时间,
Identity Server 4 原理和实战(完结)_Resource Owner Password Credentials 授权实例
今天的内容
Identity Server 4 原理和实战(完结)_Resource Owner Password Credentials 授权实例
在服务端再声明一个client端
Identity Server 4 原理和实战(完结)_Resource Owner Password Credentials 授权实例
wpf的应用的效果图
Identity Server 4 原理和实战(完结)_Resource Owner Password Credentials 授权实例

首先还是需要安装IdentityModel的库
Identity Server 4 原理和实战(完结)_Resource Owner Password Credentials 授权实例

Identity Server 4 原理和实战(完结)_Resource Owner Password Credentials 授权实例

Identity Server 4 原理和实战(完结)_Resource Owner Password Credentials 授权实例
测试程序
用户名和密码是在Testuser内
Identity Server 4 原理和实战(完结)_Resource Owner Password Credentials 授权实例
Identity Server 4 原理和实战(完结)_Resource Owner Password Credentials 授权实例

Identity Server 4 原理和实战(完结)_Resource Owner Password Credentials 授权实例

请求API资源

Identity Server 4 原理和实战(完结)_Resource Owner Password Credentials 授权实例
最上面定义一个变量用来接收Access token
Identity Server 4 原理和实战(完结)_Resource Owner Password Credentials 授权实例
代码基本上和昨天的是一样的
Identity Server 4 原理和实战(完结)_Resource Owner Password Credentials 授权实例
现请求Access token 再请求 Api1的资源

Identity Server 4 原理和实战(完结)_Resource Owner Password Credentials 授权实例
Identity Server 4 原理和实战(完结)_Resource Owner Password Credentials 授权实例

获取Identity Data的资源
Identity Server 4 原理和实战(完结)_Resource Owner Password Credentials 授权实例


在服务端设置,加上了OpenId和Profile
Identity Server 4 原理和实战(完结)_Resource Owner Password Credentials 授权实例
Identity Server 4 原理和实战(完结)_Resource Owner Password Credentials 授权实例
Identity Server 4 原理和实战(完结)_Resource Owner Password Credentials 授权实例
wpf客户端的设置
Identity Server 4 原理和实战(完结)_Resource Owner Password Credentials 授权实例

请求Identity Data的主要代码
Identity Server 4 原理和实战(完结)_Resource Owner Password Credentials 授权实例

Identity Server 4 原理和实战(完结)_Resource Owner Password Credentials 授权实例


服务器端 查看具体的代码
Identity Server 4 原理和实战(完结)_Resource Owner Password Credentials 授权实例

OpenId的官网;
Identity Server 4 原理和实战(完结)_Resource Owner Password Credentials 授权实例
Identity Server 4 原理和实战(完结)_Resource Owner Password Credentials 授权实例


这就是预设的标准的Scope

Identity Server 4 原理和实战(完结)_Resource Owner Password Credentials 授权实例

profile下面对应这些Claims
Identity Server 4 原理和实战(完结)_Resource Owner Password Credentials 授权实例

openId这个Scope是干嘛的呢?他就是表名你这个id就是请求openId connect scope的请求,所以这里的openId一定要加上。想使用下面的Profile就必须加上这里的OpenId

Identity Server 4 原理和实战(完结)_Resource Owner Password Credentials 授权实例

多增加Scope

把这四个默认的都加上
Identity Server 4 原理和实战(完结)_Resource Owner Password Credentials 授权实例

Identity Server 4 原理和实战(完结)_Resource Owner Password Credentials 授权实例

客户端也加上这几个
Identity Server 4 原理和实战(完结)_Resource Owner Password Credentials 授权实例


Identity Server 4 原理和实战(完结)_Resource Owner Password Credentials 授权实例

Identity Server 4 原理和实战(完结)_Resource Owner Password Credentials 授权实例

整个流程图

Identity Server 4 原理和实战(完结)_Resource Owner Password Credentials 授权实例


Identity Server 4 原理和实战(完结)_Resource Owner Password Credentials 授权实例






 

上一篇:Identity Server 4 中文文档(v1.0.0) 目录


下一篇:Identity Server 4 原理和实战(完结)_建立Identity Server 4项目,Client Credentials 授权实例