[TOC] ## oauth2方案背景 >[info] 通过oauth2构建的统一认证平台为用户解决了以下问题: ![](https://img.kancloud.cn/10/6a/106a35fd24ce3614b00f5b0831677a3d_1649x793.png) >[info] oauth2拥有的授权类型 ![](https://img.kancloud.cn/e8/c7/e8c7066dee869ec6a23f1d9346380054_760x433.png) ## 认证授权流程 ![](https://img.kancloud.cn/e1/6a/e16a2ecf59a3b2c9b94a6b2f1c0de2ef_1111x632.png) ## 认证中心接口地址 [http://127.0.0.1:8000/api-auth/doc.html](http://127.0.0.1:8000/api-auth/doc.html) ### 客户端模式 ![](https://img.kancloud.cn/62/02/62023a9012346b277859f05232314260_2560x1003.png) ### 密码模式 ![](https://img.kancloud.cn/eb/9e/eb9e230fc18408cde4935d639151b36b_2560x1275.png) ## 授权码模式 * 获取授权码 [ http://127.0.0.1:8000/api-auth/oauth/authorize?client_id=owen&redirect_uri=http://127.0.0.1:9997/clientOne/login&state=abc&scope=app&response_type=code](http://127.0.0.1:8000/api-auth/oauth/authorize?client_id=owen&redirect_uri=http://127.0.0.1:9997/clientOne/login&state=abc&scope=app&response_type=code) * 跳转统一登录页面,登录成功获取授权码 http://127.0.0.1:9997/clientOne/login?code=gd6jyM&state=abc ![](https://img.kancloud.cn/7b/40/7b4059e74cf81d4b6dce9988096b9b4e_2560x1211.png)