02选看OAuth2.0简介(下)-2020-10-26 09~10

原文:https://www.yuque.com/yuejiangliu/dotnet/asu0b9


           02 选看 OAuth 2.0 简介(下).mp4     (25 MB)             <a class="lake-embed-toolbar-btn " data-aspm-click="preview" data-aspm-param="unknown">                   </a>        <a class="lake-embed-toolbar-btn " data-aspm-click="download" data-aspm-param="unknown">                   </a>   

一、端点 Endpoint

  • Authorization Endpoint,授权端点

  • 在浏览器里面和用户交互

  • 资源所有者通过该端点对客户端应用进行授权操作

  • Token Endpoint,Token 端点

  • 客户端应用向该端点展示它的授权(或 Refresh Token)以获得 Access Token

                                           <i class="anticon anticon-exclamation-circle">               <svg viewbox="64 64 896 896" class="" data-icon="exclamation-circle" width="1em" height="1em" fill="currentColor" aria-hidden="true">                 <path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"></path><path d="M464 688a48 48 0 1 0 96 0 48 48 0 1 0-96 0zM488 576h48c4.4 0 8-3.6 8-8V296c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v272c0 4.4 3.6 8 8 8z"></path>               </svg>             </i>                      ![image](https://cdn.nlark.com/yuque/0/2019/png/101969/1556539887823-33598bd7-8ac4-4a81-901e-656601c8810a.png?x-oss-process=image%2Fresize%2Cw_1028)                                                               
    

二、范围 Scope

代表资源所有者在被保护资源那里的一些权限。

三、Access Token

  • 有时候就叫做 Token

  • 用来访问被保护资源的凭据

  • 代表了给客户端颁发的授权,也就是委托给客户端的权限

  • 必须描述出 Scope 和有效期

四、Refresh Token

  • 用来获取 Access Token 的凭据

  • 由 Authorization Server 颁发给客户端应用的

  • 可选

  • 具备让客户端应用逐渐降低访问权限的能力

  • Refresh 回来的 Acess Token 可能 Scope 越来越小

                                           <i class="anticon anticon-exclamation-circle">               <svg viewbox="64 64 896 896" class="" data-icon="exclamation-circle" width="1em" height="1em" fill="currentColor" aria-hidden="true">                 <path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"></path><path d="M464 688a48 48 0 1 0 96 0 48 48 0 1 0-96 0zM488 576h48c4.4 0 8-3.6 8-8V296c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v272c0 4.4 3.6 8 8 8z"></path>               </svg>             </i>                      ![image](https://cdn.nlark.com/yuque/0/2019/png/101969/1556543704958-b315b429-0f8a-49ae-8064-c72adb01f8f2.png)                                                               
    
                                           <i class="anticon anticon-exclamation-circle">               <svg viewbox="64 64 896 896" class="" data-icon="exclamation-circle" width="1em" height="1em" fill="currentColor" aria-hidden="true">                 <path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"></path><path d="M464 688a48 48 0 1 0 96 0 48 48 0 1 0-96 0zM488 576h48c4.4 0 8-3.6 8-8V296c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v272c0 4.4 3.6 8 8 8z"></path>               </svg>             </i>                      ![image](https://cdn.nlark.com/yuque/0/2019/png/101969/1556543780080-3cc2abe4-7149-43e7-90b2-b3616e37d2b6.png)                                                               
    

五、端点发生错误时

发送错误时返回:

  • error:错误类型

  • error_description

  • error_uri:指向错误详情页

  • state

  • Authorization Endpoint

  • 错误信息通过 query string 返回

  • https://xxxx.xxx.xx//authorize?error=invalid request

  • Token Endpoint

  • 错误信息通过 Post body 返回

  •                                          <i class="anticon anticon-exclamation-circle">               <svg viewbox="64 64 896 896" class="" data-icon="exclamation-circle" width="1em" height="1em" fill="currentColor" aria-hidden="true">                 <path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"></path><path d="M464 688a48 48 0 1 0 96 0 48 48 0 1 0-96 0zM488 576h48c4.4 0 8-3.6 8-8V296c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v272c0 4.4 3.6 8 8 8z"></path>               </svg>             </i>                      ![image](https://cdn.nlark.com/yuque/0/2019/png/101969/1556544059999-6c390ef3-7adf-48bc-a901-fa54988663d4.png)                                                                                                
    

六种错误类型:

  • invalid_request

  • invalid_client(401)

  • invalid_grant

  • unauthorized_client

  • unsupported_grant_type

  • invalid_scope

posted on 2022-04-28 09:18  springsnow  阅读(51)  评论(0编辑  收藏  举报

导航