[
  {
    "path": ".editorconfig",
    "content": "# JustAuth 开发组IDE 编辑器标准\nroot = true\n\n# 空格替代Tab缩进在各种编辑工具下效果一致\n[*]\nindent_style = space\nindent_size = 2\ncharset = utf-8\nend_of_line = lf\ntrim_trailing_whitespace = true\ninsert_final_newline = true\n\n[*.java]\nindent_size = 4\n\n[*.md]\ninsert_final_newline = false\ntrim_trailing_whitespace = false\n\n"
  },
  {
    "path": ".gitee/ISSUE_TEMPLATE.zh-CN.md",
    "content": "为更快的帮您定位问题，推荐您用以下模板反馈问题：\n\n### 1. 出现问题时，您做了哪些操作？\n\n### 2. 在哪个步骤出现了问题？\n\n### 3. 您希望得到什么结果？\n\n### 4. 您实际得到什么结果？\n\n### 5. 请附上您出现问题的整屏截图或者整个异常堆栈信息\n\n"
  },
  {
    "path": ".gitee/PULL_REQUEST_TEMPLATE.zh-CN.md",
    "content": "- [ ] 是否为解决Issue？\n\n\n### 您做了哪些更新？\n\n- 新增\n\n- 修改\n\n- 修复\n\n- 其他\n\n\n### 是否做了充分测试？\n\n- [ ] 是，已经做过测试，并且测试通过\n- [ ] 否，还没做测试，需要作者自测\n\n注：测试demo可以使用：\n- [simple版](https://github.com/justauth/JustAuth-demo)\n- [jFinal版](https://github.com/xkcoding/jfinal-justauth-demo)\n- [ActFramework版](https://github.com/xkcoding/act-justauth-demo)\n- [Nutzboot版](https://github.com/EggsBlue/nutzboot-justauth-demo)\n- [Blade版](https://github.com/justauth/blade-justauth-demo)\n\n\n\n\n"
  },
  {
    "path": ".github/FUNDING.yml",
    "content": "# These are supported funding model platforms\n\ngithub: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]\npatreon: # Replace with a single Patreon username\nopen_collective: # Replace with a single Open Collective username\nko_fi: # Replace with a single Ko-fi username\ntidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel\ncommunity_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry\nliberapay: # Replace with a single Liberapay username\nissuehunt: # Replace with a single IssueHunt username\notechie: # Replace with a single Otechie username\ncustom: ['https://www.justauth.cn/sponsor.html']\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/bug_report.md",
    "content": "---\nname: Bug report template\nabout: Please use this template for reporting suspected bugs.\ntitle: 'bug:'\nlabels: 'bug'\nassignees: ''\n---\n\n## Pre-submission checklist:\n\n- [ ] I have searched the relevant information in the existing list of Issues.\n- [ ] I have searched the developer documentation for that information: https://www.justauth.cn\n- [ ] I have read the relevant Q&A: https://www.justauth.cn\n\n## Issue description\n\n## Environment\n\n- JustAuth version(e.g. `1.15.1`): \n\n### Minimal test code / Steps to reproduce the issue\n1.\n2.\n3.\n\n## What's the actual result? (including assertion message & call stack if applicable)\n\n> Be sure to provide a complete and detailed exception stack.\n\n\n## What's the expected result?\n\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/feature_request.md",
    "content": "---\nname: Feature Request\nabout: Please use this template for describing new features.\ntitle: 'feat: '\nlabels: 'Feature Request'\nassignees: ''\n---\n\n## Why did you add this feature?\n\n## Feature description\n\n\n\n\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/request-help.md",
    "content": "---\nname: Request help template\nabout: Please use this template for requesting help.\ntitle: 'request help:'\nlabels: 'question'\nassignees: ''\n\n---\n\n\n## Issue description\n\n## Environment\n\n- JustAuth version(e.g. `1.15.1`): "
  },
  {
    "path": ".github/PULL_REQUEST_TEMPLATE.md",
    "content": "## What this PR does / why we need it:\n\n\n## Pre-submission checklist:\n- [ ] Did you explain what problem does this PR solve?\n- [ ] What new features have been added?\n- [ ] Have you added corresponding test cases?\n- [ ] Have you modified the corresponding document?\n- [ ] Is this PR backward compatible?\n\n\n\n\n"
  },
  {
    "path": ".github/workflows/deploy-snapshot.yml",
    "content": "name: Deploy\n\non: \n  push:\n    branches: [ dev ]\n    paths:\n      - src/**\n      - pom.xml\n\njobs:\n  test:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v2.2.0\n      - name: Set up Java and Maven\n        uses: actions/setup-java@v2\n        with:\n          java-version: '8'\n          distribution: 'zulu'\n      - name: Cache m2 package\n        uses: actions/cache@v2\n        with:\n          path: ~/.m2/repository\n          key: ${{ runner.os }}-maven-${{ hashFiles('pom.xml') }}\n          restore-keys: |\n            ${{ runner.os }}-maven-\n      - run: mvn test\n\n  deploy-snapshot:\n    needs: test\n    if: ${{ success() }}\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v2.2.0\n      - name: Set up Java and Maven\n        uses: actions/setup-java@v2\n        with:\n          java-version: '8'\n          distribution: 'zulu'\n          server-id: ossrh\n          server-username: MAVEN_USERNAME\n          server-password: MAVEN_PASSWORD\n      - name: Cache m2 package\n        uses: actions/cache@v2\n        with:\n          path: ~/.m2/repository\n          key: ${{ runner.os }}-maven-${{ hashFiles('pom.xml') }}\n          restore-keys: |\n            ${{ runner.os }}-maven-\n      - name: setting snapshot version\n        run: |\n          import xml.etree.ElementTree as ET\n          tree = ET.parse(\"pom.xml\")\n          version = tree.find(\"{http://maven.apache.org/POM/4.0.0}version\")\n          print(version.text + \"-SNAPSHOT\")\n          if version.text.endswith(\"-SNAPSHOT\") == False:\n            tree.find(\"{http://maven.apache.org/POM/4.0.0}version\").text = version.text + \"-SNAPSHOT\"\n            ET.register_namespace(\"\", \"http://maven.apache.org/POM/4.0.0\")\n            tree.write(\"pom.xml\", \"utf-8\", True)\n        shell: python\n      - name: deploy snapshot to ossrh repository\n        run: mvn -B deploy -P snapshot -DskipTests\n        env:\n          MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}\n          MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}\n"
  },
  {
    "path": ".github/workflows/test-pr.yml",
    "content": "name: test pull_request\n\non: \n  pull_request:\n    paths:\n      - src/**\n      - pom.xml\n\njobs:\n  test:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v2.2.0\n      - name: Set up Java and Maven\n        uses: actions/setup-java@v2\n        with:\n          java-version: '8'\n          distribution: 'zulu'\n      - name: Cache m2 package\n        uses: actions/cache@v2\n        with:\n          path: ~/.m2/repository\n          key: ${{ runner.os }}-maven-${{ hashFiles('pom.xml') }}\n          restore-keys: |\n            ${{ runner.os }}-maven-\n      - run: mvn test\n"
  },
  {
    "path": ".gitignore",
    "content": "# Compiled class file\n*.class\n\n# Log file\n*.log\n\n# BlueJ files\n*.ctxt\n\n# Mobile Tools for Java (J2ME)\n.mtj.tmp/\n\n# Package Files #\n*.jar\n*.war\n*.nar\n*.ear\n*.zip\n*.tar.gz\n*.rarp\n\n# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml\nhs_err_pid*\n\n# exclude idea files\n.idea\n*.iml\nbin/codecov.sh\nbin/deploy.sh\nbin/docsify-cli.sh\n\ntarget\n/pom.xml.versionsBackup\n/gpg\n/PLAN.md\n"
  },
  {
    "path": ".travis.yml",
    "content": "language: java\n\nsudo: false # faster builds\n\ninstall: true\n\njdk:\n  - openjdk8\n\nnotifications:\n  email: false\n\nscript:\n  - export TZ=Asia/Shanghai\n  - mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V\n  - mvn cobertura:cobertura -Dcobertura.report.format=xml -Dmaven.javadoc.skip.true\n\nafter_success:\n  - bash <(curl -s https://codecov.io/bash)\n"
  },
  {
    "path": "CHANGELOGS.md",
    "content": "## 1.16.7\n\n### 2024/12/14\n\n- 新增\n  - 添加`微信小程序`登录能力，对接文档：[点击查看](https://justauth.cn/guide/oauth/wechat_mini_program/)。\n  - 添加`支付宝证书模式`登录能力（原支持的公钥登录模式依然可用），对接文档：[点击查看](https://justauth.cn/guide/oauth/alipay_cert)。\n  - 添加`appleid`社交登录能力，对接文档：[点击查看](https://justauth.cn/guide/oauth/appleid/)。 [Github#192](https://github.com/justauth/JustAuth/pull/192)\n  - 添加`QQ小程序`社交登录能力。 [Github#223](https://github.com/justauth/JustAuth/pull/223)\n  - 添加`figma`社交登录能力。 [Gitee#41](https://gitee.com/yadong.zhang/JustAuth/pulls/41)\n  - 添加新版`企业微信扫码`登录能力，对接文档：[点击查看](https://justauth.cn/guide/oauth/wechat_enterprise_qrcode_v2/)。 [Github Issue#165](https://github.com/justauth/JustAuth/issues/165)\n  - 添加新版`钉钉扫码`登录能力，对接文档：[点击查看](https://justauth.cn/guide/oauth/dingtalk_v2/)。 [Gitee Issue#I73FZL](https://gitee.com/yadong.zhang/JustAuth/issues/I73FZL)\n  - 添加新版`华为`登录能力，对接文档：[点击查看](https://justauth.cn/guide/oauth/huawei_v3/)，原`AuthHuaweiRequest`会在后面版本被弃用，如有使用，请切换到`AuthHuaweiV3Request`\n- 优化\n  - 修复文档错误。[Github #222](https://github.com/justauth/JustAuth/pull/222)\n  - 更新 Google 端点地址。[Github #198](https://github.com/justauth/JustAuth/pull/198)\n  - Amazon PKCE 中的 `code_verifier` 基于 `state` 缓存\n  - `AuthRequest`响应时携带泛型，避免二次解析。[Gitee#38](https://gitee.com/yadong.zhang/JustAuth/pulls/38)\n  - 优化业务调用方式：`getAccessToken`和`getUserInfo`两个方法从`AuthDefaultRequest`提升至`AuthRequest`中，部分场景下可以减少一次网络请求。[Github Issue#194](https://github.com/justauth/JustAuth/issues/194)\n    - ***注意：如果有基于 JustAuth 规范自定义实现的三方平台 Request（[自定义第三方平台的OAuth](https://justauth.cn/features/customize-the-oauth/)），需要注意`getAccessToken`和`getUserInfo`接口的访问级别是否正确！！！***\n- 其他\n  -  补充单侧，[Gitee#39](https://gitee.com/yadong.zhang/JustAuth/pulls/39)\n\n## 1.16.6\n\n### 2023/12/03\n- 优化\n  - 微信公众平台支持返回快照标识（快照标识为 true 时，标识当前获取到的微信用户信息都是虚拟的）\n  - 企业微信网页登录--获取用户敏感信。 [Github #155](https://github.com/justauth/JustAuth/pull/155)\n  - 添加飞书单元测试。 [Github #159](https://github.com/justauth/JustAuth/pull/159)\n  - 升级fastjson版本到1.2.83，1.2.83版本之前存在代码执行漏洞风险 ，CVE-2022-25845。[Gitee PR #31](https://gitee.com/yadong.zhang/JustAuth/pulls/31)\n- 新增\n  - 添加微软中国(世纪华联)第三方登录，新增微软方式登录的redirectUri校验。[Gitee PR #33](https://gitee.com/yadong.zhang/JustAuth/pulls/33)\n  - 新增爱发电平台 [Gitee #35](https://gitee.com/yadong.zhang/JustAuth/pulls/35)\n  - 微软平台适配 AzureAD（目前改名为 Microsoft Entra ID）登录认证\n- Fixed\n  - 修复 twitter 平台在 Java11 环境下登录失败的问题。[#174](https://github.com/justauth/JustAuth/issues/174)\n  - 修复 Facebook 平台无法登录的问题（facebook 平台 API 进行了升级）\n  - 修复微信公众平台 scope 为 snsapi_base 登录报错的问题 [181](https://github.com/justauth/JustAuth/issues/181)\n\n## 1.16.5\n\n### 2021/10/18\n\n- 合并 PR [Github #138](https://github.com/justauth/JustAuth/pull/138)\n- 升级alipay-sdk-version的依赖版本\n- 修改用户logo的尺寸\n- 修复 alipay 登录失败的 BUG [Gitee Issue #I4E4ML](https://gitee.com/yadong.zhang/JustAuth/issues/I4E4ML)\n\n\n## 1.16.4\n\n### 2021/9/22\n\n- 合并 PR \n  - [Github #134](https://github.com/justauth/JustAuth/pull/134)\n  - [Github #133](https://github.com/justauth/JustAuth/pull/133)\n  - [Github #132](https://github.com/justauth/JustAuth/pull/132)\n  - [Github #131](https://github.com/justauth/JustAuth/pull/131)\n- 添加微软中国(世纪华联)第三方登录，新增微软方式登录的redirectUri校验。[Gitee PR #28](https://gitee.com/yadong.zhang/JustAuth/pulls/28)\n- 升级第三方的依赖\n  -  simple-http > 1.0.5 \n  -  lombok > 1.18.20\n  -  junit > 4.13.2\n  -  fastjson > 1.2.78\n  -  alipay-sdk > 4.16.38.ALL\n\n## 1.16.3\n\n### 2021/8/15\n\n- 发布 v1.16.3\n- 新增\n  - 集成“企业微信的第三方应用”平台登录\n- PR\n  - `AuthRequst` 增加 `Builder` 构建方式，使用起来更简单。 ([#27](https://gitee.com/yadong.zhang/JustAuth/pulls/27))\n  - 使用 Github Action 添加发布快照的 workflow。 ([#126](https://github.com/justauth/JustAuth/pull/126))\n  - 新增了企业微信的第三方应用登录，`AuthWeChatEnterpriseThirdQrcodeRequest`。 ([#127](https://github.com/justauth/JustAuth/pull/127))\n  - 添加快照版本对应更详细的文档。 ([#128](https://github.com/justauth/JustAuth/pull/128))\n- 修改\n  - 在 Gitee PR ([#27](https://gitee.com/yadong.zhang/JustAuth/pulls/27)) 的基础上重构代码，增加 Builder 方式创建 AuthRequest\n  - 解决 Line 登录的错误。[#122](https://github.com/justauth/JustAuth/issues/122)\n  \n\n## 1.16.2\n\n### 2021/7/28\n\n- 发布 v1.16.2\n- 新增\n  - 集成“程序员客栈”平台登录\n- 修改\n  - 更新文档\n  - 修复“淘宝”平台授权登录后没有`uid`的问题、增加刷新token的功能\n  - 修复“Twitter”平台授权登录后获取不到用户邮箱的问题\n\n## 1.16.1\n\n### 2021/4/19\n\n- 发布 v1.16.1\n- Fix Github issue [#114](https://github.com/justauth/JustAuth/issues/114): 解决企业微信授权后,回调地址中原有的参数丢失的问题\n- Fix Github issue [#82](https://github.com/justauth/JustAuth/issues/82): 抖音平台支持自定义 scope\n- Fix Github issue [#92](https://github.com/justauth/JustAuth/issues/92): 增加忽略校验 redirectUri 的配置\n- Merge Github PR [#115](https://github.com/justauth/JustAuth/pull/115)\n- 升级 `fastjson` 到 `v1.2.76`\n  \n## 1.16.0\n\n### 2021/4/7\n\n- 发布 v1.16.0\n- 新增\n  - 集成 Amazon 平台登录\n  - 集成 Slack 平台登录\n  - 集成 LINE 平台登录\n  - 集成 Okta 平台登录\n  - 集成钉钉账号登录\n- 修改 \n  - 【**重要**】 `AuthConfig`中的`codingGroupName`参数更名为`domainPrefix`，针对此类平台提供通用的配置。\n  - 修改 `AuthFacebookScope` 中的默认 scope，解决 justauth-demo 项目中使用 facebook 报错的问题\n  - 升级 facebook 的 api 到 v10.0 版本\n  - 优化部分代码\n  - 优化 Map 声明时的初始容量，避免频繁扩容\n  - 更新 README 文档\n- PR\n  - 合并 [Github #110](https://github.com/justauth/JustAuth/pull/110) \n  - 合并 [Gitee #22](https://gitee.com/yadong.zhang/JustAuth/pulls/22) \n\n## 1.15.9\n\n### 2021/1/1\n\n- 发布 v1.15.9\n- 新增\n    - 修复并正式启用 飞书 平台的第三方登录\n    - AuthToken 类中新增 `refreshTokenExpireIn` 记录 refresh token 的有效期\n- PR\n    - 合并 [Github #101](https://github.com/justauth/JustAuth/pull/101) ：支持喜马拉雅登录\n    - 合并 [Github #105](https://github.com/justauth/JustAuth/pull/105) ：支持企业微信网页授权登录\n    - 合并 [Github #107](https://github.com/justauth/JustAuth/pull/107) ：添加AuthAlipayRequest网络代理构造器，解决 Github Issue [#102](https://github.com/justauth/JustAuth/issues/102)\n- 修改\n    - 修改喜马拉雅配置参数，将`ClientOsType`参数提到 AuthConfig 中\n    - AuthChecker 中增加对喜马拉雅平台的校验\n    - 升级 facebook api 版本到 v9.0，解决 Gitee Issue [#I2AR5S](https://gitee.com/yadong.zhang/JustAuth/issues/I2AR5S)\n    - ！！！**注意**！！！修改原来的企业微信 Request 类名为 `AuthWeChatEnterpriseQrcodeRequest`，升级后注意该点\n\n注意：可能有些开发者对于 JA 集成的四个微信平台不太理解，这儿统一说明：\n- 按照类名\n    - AuthWeChatEnterpriseQrcodeRequest：企业微信二维码登录\n    - AuthWeChatEnterpriseWebRequest：企业微信网页登录\n    - AuthWeChatOpenRequest：微信开放平台\n    - AuthWeChatMpRequest：微信公众平台\n- 按照枚举\n    - WECHAT_ENTERPRISE：企业微信二维码登录\n    - WECHAT_ENTERPRISE_WEB：企业微信网页登录\n    - WECHAT_OPEN：微信开放平台\n    - WECHAT_MP：微信公众平台\n    \n## 1.15.8\n\n### 2020/10/25\n\n- Release version 1.15.8\n- Merge the pr. [#95](https://github.com/justauth/JustAuth/pull/95) [#96](https://github.com/justauth/JustAuth/pull/96)\n\n## 1.15.7\n\n### 2020/09/11\n\n- Release version 1.15.7\n- Upgrade the use of access token when obtaining resources on the github platform.Reference from [Deprecating API authentication through query parameters](https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/)\n- Fixed issue. [#89](https://github.com/justauth/JustAuth/issues/89)\n\n## 1.15.7-beta.3\n\n### 2020/08/24\n\n- Fixing a bug for wechat.\n- Improve the Microsoft platform's questions about scope.\n\n## 1.15.7-beta.1\n\n### 2020/08/05\n\n- 新增\n    - 以下平台支持自定义 Scope 参数：百度、coding、Facebook、gitee、github、gitlab、google、华为、京东·宙斯、酷家乐、领英、微软、小米、Pinterest、QQ、人人网、StackOverflow、微博、微信公众平台\n    - 添加 PR 和 ISSUE 规范和 CODE_OF_CONDUCT 文档\n- 合并\n    - 合并 Gitee [PR#19](https://gitee.com/yadong.zhang/JustAuth/pulls/19)，修复通过google登录一次后，重新用google登录无法切换谷歌账户的问题。\n\n## 1.15.6\n\n### 2020/06/30\n- 文档\n    - 新增 [百度登录](oauth/baidu.md)文档\n    - 新增 [钉钉登录](oauth/alipay.md)文档\n    - 新增 [开源中国登录](contributors.md)文档\n    - 新增 [领英登录](references.md)文档\n    - 新增 [Google 登录](references.md)文档\n    - 新增 [微信企业版登录](oauth/wechatEnterprise.md)文档\n    - 新增 [Facebook 登录](oauth/facebook.md)文档\n    - 完善 [JustAuth 使用者](users.md)文档\n    - 替换“帮助文档”域名，由[https://docs.justauth.whnb.wang](https://docs.justauth.whnb.wang)迁移到[https://www.justauth.cn](https://www.justauth.cn)\n- 新增\n    - 增加阿里云授权登录中刷新授权token的接口，by “QQ群用户需求”\n    - AuthConfig 增加忽略校验 state 的参数，详情参考：[Github#Issue#83](https://github.com/justauth/JustAuth/issues/83)\n    - 移除领英刷新token的接口。参考官网：`To refresh an access token, go through the authorization process again to fetch a new token.`\n\n## 1.15.5\n### 2020/06/24\n- BUG\n    - 解决 `Microsoft` 授权失败的 BUG\n    - 解决 `Coding` 个人账号授权失败的 BUG（目前只能使用团队模式进行授权，需要传入团队名，参考`AuthConfig#codingGroupName`）\n    - 解决 `AuthLinkedinRequest#getAvatar` NPE 的问题。（领英用户没有头像时，原代码会报 NPE）\n    - 解决抖音登录获取用户地址异常的问题。\n    - 解决人人网登录时 token 中带有 `|` 引起的异常，[Gitee!15](https://gitee.com/yadong.zhang/JustAuth/pulls/15)\n- 新增\n    - 支持阿里云授权登录，[Github#81](https://github.com/justauth/JustAuth/pull/81)\n    - AuthUser 中新增 `rawUserInfo`，用来存放第三方平台返回的原始用户数据。注：淘宝平台的`rawUserInfo`为一个空 JSON\n    - 支持 Http 级的代理配置，使用方式：\n```java\nnew AuthGoogleRequest(AuthConfig.builder()\n    .clientId(\"\")\n    .clientSecret(\"\")\n    .redirectUri(\"http://127.0.0.1:8443/oauth/callback/google\")\n    // 针对国外平台配置代理\n    .httpConfig(HttpConfig.builder()\n            .timeout(15000)\n            .proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(\"127.0.0.1\", 10080)))\n            .build())\n    .build());\n```\n- 修改\n    - 升级 [simple-http](https://github.com/xkcoding/simple-http) 到 `v1.0.2`\n    - 升级 `fastjson` 到 `v1.2.71`\n- 删除\n    - :boom: 删除**腾讯云登录**。coding 已并入 腾讯云，因此只保留 coding 登录 :boom:\n- 文档\n    - 新增 [Coding登录](oauth/coding.md)文档\n    - 完善 [支付宝登录](oauth/alipay.md)文档\n    - 完善 [贡献者名单](contributors.md)文档\n    - 完善 [参考文档](references.md)文档\n- PR\n    - 合并 [Gitee!17](https://gitee.com/yadong.zhang/JustAuth/pulls/17)\n    - 合并 [Gitee!15](https://gitee.com/yadong.zhang/JustAuth/pulls/15)\n    - 合并 [Github#81](https://github.com/justauth/JustAuth/pull/81)\n- Issues\n    - 解决 [Github#80](https://github.com/justauth/JustAuth/issues/80)\n    - 解决 [Github#75](https://github.com/justauth/JustAuth/issues/75)\n    \n## 1.15.4-alpha\n### 2020/05/13\n- 修复\n    - 解决 Twitter 授权失败的BUG\n- 文档\n    - 完善 [https://www.justauth.cn](https://www.justauth.cn/) 的404引导页内容\n    - 增加名词解释： `uuid`\n    - 补充 [Q&A](Q&A.md)\n    - 新增 [参考文档](references.md)，包含 OAuth 授权和第三方平台的API文档等内容\n    - 新增 [推特登录](oauth/twitter.md) 的说明文档\n\n> 特别注意：所有国外平台都无法直接通过java进行访问API，目前[simple-http](https://github.com/xkcoding/simple-http) Release版本，暂不支持添加代理，所以目前需要手动开启代理。\n\n代理开启的方式：\n```java\nSystem.setProperty(\"proxyPort\", \"10080\");\nSystem.setProperty(\"proxyHost\", \"127.0.0.1\");\n```\n以上代码可以在声明 `AuthRequest` 时创建，也可以全局执行。\n\n本地如果支持科学上网，就用自己本地的代理端口即可，如果不支持科学上网，可以去网上找一些免费的代理IP进行测试（请自行操作）。\n\n\n## 1.15.2-alpha\n### 2020/05/10\n- 修改\n    - 修复使用领英登录时无法获取token的问题\n    - 解决Gitee [Issue-I1GPIB](https://gitee.com/yadong.zhang/JustAuth/issues/I1GPIB)\n\n【声明】：当引用 OkHttp 时，无法调用领英的授权登录，可能会抛出 400 异常。如遇此问题，请先切换到 hutool 或者 httpclient 依赖。\n该问题尚在修复中，给各位带来的不便，深表歉意。\n\n- hutool-http\n\n  ```xml\n  <dependency>\n      <groupId>cn.hutool</groupId>\n      <artifactId>hutool-http</artifactId>\n      <version>5.2.5</version>\n  </dependency>\n  ```\n\n- httpclient\n\n  ```xml\n  <dependency>\n  \t<groupId>org.apache.httpcomponents</groupId>\n    \t<artifactId>httpclient</artifactId>\n    \t<version>4.5.12</version>\n  </dependency>\n  ```\n\n## v1.15.1(~~v1.15.0~~)\n### 2020/04/10\n- 修改\n    - 更新开发文档\n    - 合并Gitee [PR-10](https://gitee.com/yadong.zhang/JustAuth/pulls/10)，集成京东登录\n    - 合并Gitee [PR-14](https://gitee.com/yadong.zhang/JustAuth/pulls/14)，修改帮助文档，加入JA的使用者信息\n    - 合并Github [PR-69](https://github.com/justauth/JustAuth/pull/69)，升级fastjson的最新版本\n    - 解决使用apache-httpclient时的403bug，升级simple-http，感谢QQ群的`不瘦十斤不改名字`反馈该问题\n    - 修复其他一些问题\n\n【声明】：由于本人的失误，发布了一个错误的版本（1.15.0），目前1.15.0已发布，但是请不要使用，请直接升级到`1.15.1`。\n\n给各位造成的不便，深表歉意。\n    \n## v1.14.0\n### 2020/03/17\n- 修改\n    - 合并[PR-59](https://github.com/justauth/JustAuth/pull/59)，抽取HTTP，具体实现交给开发者，解耦 hutool-http，开发者可以视自己项目的依赖决定使用何种HTTP方式。详情请参考：https://github.com/xkcoding/simple-http\n    - 合并[PR-65](https://github.com/justauth/JustAuth/pull/65)，修改错误文案\n    - 修复其他一些问题\n    \n## v1.14.0\n### 2020/03/17\n- 修改\n    - 合并[PR-59](https://github.com/justauth/JustAuth/pull/59)，抽取HTTP，具体实现交给开发者，解耦 hutool-http，开发者可以视自己项目的依赖决定使用何种HTTP方式。详情请参考：https://github.com/xkcoding/simple-http\n    - 合并[PR-65](https://github.com/justauth/JustAuth/pull/65)，修改错误文案\n    - 修复其他一些问题\n\n## v1.13.2\n### 2019/12/24\n- 新增\n    - 增加微信、QQ、支付宝、微博授权登录的帮助文档\n    - 合并[PR#57](https://github.com/justauth/JustAuth/pull/57)，增加微信公众号登录 by [@xkcoding](https://github.com/xkcoding)\n    - [帮助文档](https://www.justauth.cn)中增加自定义的404页面\n    - [帮助文档](https://www.justauth.cn)中增加Gittalk插件\n    - [帮助文档](https://www.justauth.cn)中增加Java代码高亮的插件\n    - 增加`AuthUserGender#getWechatRealGender`方法，兼容获取微信平台的用户性别\n- 修改\n    - 修复抖音登录取值取错层级的问题（[issue#I15SIG@Gitee](https://gitee.com/yadong.zhang/JustAuth/issues/I15SIG)）\n    - 完善异常提示的逻辑，支持传入Source（平台），发生异常时显示对应的source（平台）\n    - `checkState`方法从`AuthDefaultRequest`中提出到`AuthChecker`中\n    - `AuthResponseStatus`枚举类中增加`ILLEGAL_STATUS`、`REQUIRED_REFRESH_TOKEN`两个枚举值\n    - `AuthSource`接口中增加`getName`方法，用来对外提供实际`source`的字符串值\n    - `AuthWeiboRequest`微博授权登录中实现`revoke`方法，支持手动回收授权\n    - [帮助文档](https://www.justauth.cn)中修复[腾讯云登录]链接错误的问题\n- 升级\n    - 升级相关依赖：lombok@v1.18.10，hutool@5.0.5，fastjson@1.2.62，alipay@4.8.10.ALL（[PR#11@Gitee](https://gitee.com/yadong.zhang/JustAuth/pulls/11)）\n\n\n## v1.13.1\n### 2019/11/12\n\n- 修复[Issue#52](https://github.com/justauth/JustAuth/issues/52)，解决AuthCallback异常的问题。请正在使用 `v1.13.0`的朋友升级到`v1.13.1`\n\n## v1.13.0\n### 2019/11/01\n\n- 集成“推特”\n- 完善文档\n\n## v1.12.0\n### 2019/09/06\n\n- 集成“美团”授权登录\n- 集成“饿了么”授权登录\n- 升级Fastjson依赖到1.2.60，预防[“Fastjson ＜ 1.2.60 远程拒绝服务漏洞预警”](https://card.weibo.com/article/m/show/id/2309404413257925394542)\n- 添加Nutzboot版的demo\n- 提取公共的Source接口，支持自定义扩展第三方平台的授权登录，具体扩展例子可参考[AuthExtendRequest](https://gitee.com/yadong.zhang/JustAuth/blob/master/src/test/java/me/zhyd/oauth/request/AuthExtendRequest.java)\n\n## v1.11.0\n### 2019/09/03\n\n- 集成“Gitlab”授权登录\n\n### 2019/09/02\n\n- 集成“酷家乐”授权登录\n\n## v1.10.1\n### 2019/08/17\n\n- AuthUser添加构造函数，支持反序列化\n\n### 2019/08/08\n\n- 项目迁移到组织[justauth](https://github.com/justauth)\n\n## v1.10.0\n### 2019/08/06\n\n- 合并[PR-34](https://github.com/zhangyd-c/JustAuth/pull/34)，添加StringUtil单元测试，修复bug\n- 合并[PR-35](https://github.com/zhangyd-c/JustAuth/pull/35)，集成企业微信\n\n### 2019/08/05\n\n- 集成华为登录\n- 修改`AuthChecker#checkCode`方法，对于不同平台使用不同参数接受code的情况统一做处理\n\n### 2019/08/03\n\n合并github上[xkcoding](https://github.com/xkcoding) 的[pr#32](https://github.com/zhangyd-c/JustAuth/pull/32)，抽取 cache 接口，方便用户自行集成 cache\n\n### 2019/08/02\n\n- 增加`AuthCache`配置类`AuthCacheConfig.java`，可以自定义缓存有效期以及是否开启定时任务\n- 去掉`slf4j`依赖，封装`Log.java`工具类\n- 规范测试类\n\n## v1.9.5\n### 2019/07/31 \n\n`v1.9.4`版本发布失败，请升级到`1.9.5`版本！\n\n由此给您带来的不便，敬请谅解！\n\n## v1.9.4\n### 2019/07/30 \n\n1. 升级`hutool-http`版本到`v4.6.1`\n2. 去除`AuthCallback`中增加的默认的校验state的方法，挪到`AuthDefaultRequest`中做统一处理\n3. `alipay-sdk-java`依赖改为`provided`，如果需要使用支付宝登录，需要使用方手动引入相关依赖，具体操作方式，见项目WIKI；\n4. 规范注释\n\n## v1.9.3\n### 2019/07/30 \n\n1. 规范注释\n2. 增加State缓存，`AuthCallback`中增加默认的校验state的方法\n3. 增加默认的state生成方法，参考`AuthStateUtils.java`和`UuidUtils.java`\n4. 升级`hutool-http`版本到`v4.6.0`\n5. 修复其他一些问题\n\n### 2019/07/27\n\n1. `IpUtils.getIp`改名为`IpUtils.getLocalIp`\n2. 规范注释\n\n### 2019/07/25\n\n1. `AuthConfig`类中去掉state参数\n2. 删除`AuthState`类\n3. 增加`authorize(String)`方法，并且使用`@Deprecated`标记`authorize()`方法\n\n## v1.9.2\n### 2019/07/22  \n1. 合并github上[xkcoding](https://github.com/xkcoding) 的[pr#26](https://github.com/zhangyd-c/JustAuth/pull/26)，AuthConfig类添加lombok注解，方便 [justauth-spring-boot-starter](https://github.com/xkcoding/justauth-spring-boot-starter) 直接使用 \n\n## v1.9.1\n### 2019/07/22  \n1. 增加`stackoverflow`参数校验\n2. 解决`Pinterest`获取用户失败的问题\n3. 添加注释\n\n## v1.9.0\n### 2019/07/19  \n\n1. 合并github上[@dyc12ii](https://github.com/dyc12ii) 的[pr#25](https://github.com/zhangyd-c/JustAuth/pull/25)，升级fastjson版本至1.2.58,避免安全漏洞\n2. `AuthUserGender`枚举类挪到`enums`包下\n3. 删除`AuthBaiduErrorCode`和`AuthDingTalkErrorCode`枚举类\n4. 优化百度授权流程，增加refresh token的方法\n5. 优化`AuthConfig`、`AuthResponse`类，去掉不必要的lombonk注解，减少编译后的代码量\n6. 使用lombok注解优化枚举类\n7. `AuthQqRequest`增加refresh方法\n8. 修复google登录无法获取用户信息的问题\n9. 优化代码\n\n### 2019/07/18\n\n1. 合并github上[@pengisgood](https://github.com/pengisgood) 的[pr#19](https://github.com/zhangyd-c/JustAuth/pull/19)，集成人人\n2. 合并github上[@pengisgood](https://github.com/pengisgood) 的[pr#20](https://github.com/zhangyd-c/JustAuth/pull/20)，集成Pinterest\n3. 合并github上[@pengisgood](https://github.com/pengisgood) 的[pr#21](https://github.com/zhangyd-c/JustAuth/pull/21)，集成StackOverflow\n4. 合并github上[@xkcoding](https://github.com/xkcoding) 的[pr#23](https://github.com/zhangyd-c/JustAuth/pull/23)，重构代码、新增编辑器规范，规范PR代码风格\n\n### 2019/07/17\n1. 优化代码\n2. 集成Teambition登录\n\n### 2019/07/16\n1. 重构UrlBuilder类\n2. 将CSDN相关的类置为`Deprecated`，后续可能会删除，也可能一直保留。毕竟CSDN的openAPI已经不对外开放了。\n3. `BaseAuthRequest` 改名为 `AuthDefaultRequest`\n4. `ResponseStatus` 改名为 `AuthResponseStatus` 并且移动到 `me.zhyd.oauth.model`\n5. 合并github上[@xkcoding](https://github.com/xkcoding) 的[pr#18](https://github.com/zhangyd-c/JustAuth/pull/18)，修复小米回调错误问题 同时 支持微信获取unionId \n\n## v1.8.1\n### 2019/07/15 \n1. 新增 `AuthState` 类，内置默认的state生成规则和校验规则\n\n### 2019/07/12\n1. 合并[Braavos96](https://github.com/Braavos96)提交的[PR#16](https://github.com/zhangyd-c/JustAuth/pull/16)\n\n## v1.8.0\n### 2019/06/28 \n1. 修复百度登录获取不到token失效时间的问题\n2. 增加state参数校验，预防CSRF。**强烈建议启用state**！\n\n### 2019/06/27\n1. 修复百度登录获取不到token失效时间的问题\n2. 增加state参数校验，预防CSRF。**强烈建议启用state**！\n3. 修改login方法的参数为AuthCallback，封装回调返回的参数\n4. 支持state参数\n5. 增加code和state参数校验\n\n由于state安全问题，1.8.0以前的版本都有隐藏的CSRF漏洞问题，所以强烈建议正在使用JustAuth的朋友升级到1.8.0版本！\n\n## v1.7.1\n### 2019/06/25  \nqq授权登录时，需要获取`openId`作为`uuid`，在`1.6.1-beta`和`1.7.0`版本中，引入了`unionId`这一属性。获取`unionid`需要单独向qq团队**发送邮件**申请权限，鉴于这一申请权限的步骤比较麻烦（需要填写的内容比较多），所以在`AuthConfig`中增加了一个`unionId`属性，当为**true**时才会获取unionid，当为false时只获取openId。如果你需要该功能， 则在自行申请了相关权限后，将该属性置为true即可。关于unionId的参考链接：[UnionID介绍](http://wiki.connect.qq.com/unionid%E4%BB%8B%E7%BB%8D)\n\n## v1.7.0\n### 2019/06/19  \n1. 合并[xkcoding](https://github.com/xkcoding)提交的[PR](https://github.com/zhangyd-c/JustAuth/pull/14)，重构了部分代码，jar包由原来的`130+kb`优化到现在的`110+kb`\n2. 合并[skqing](https://gitee.com/skqing)提交的[PR](https://gitee.com/yadong.zhang/JustAuth/pulls/3)， 解决抖音登录失败问题 \n\n## v1.6.1-beta\n### 2019/06/18  \n1. 解决Issue [#IY2HW](https://gitee.com/yadong.zhang/JustAuth/issues/IY2HW)\n2. 解决Issue [#IY2OH](https://gitee.com/yadong.zhang/JustAuth/issues/IY2OH)\n3. 解决Issue [#IY2FV](https://gitee.com/yadong.zhang/JustAuth/issues/IY2FV)\n4. 修复部分注释、拼写错误\n5. 解决Issue [#IY1QR](https://gitee.com/yadong.zhang/JustAuth/issues/IY1QR) 增加对Config属性的校验功能，主要校验redirect uri的合法性\n6. 合并[skqing](https://gitee.com/skqing)提交的[PR](https://gitee.com/yadong.zhang/JustAuth/pulls/2)，解决一些BUG\n\n## v1.6.0-beta\n### 2019/06/06  \n1. 增加今日头条的授权登陆\n2. 发布1.6.0-beta版本，今日头条开发者暂时不能认证， 所以无法做测试，等测试通过后，正式发布release版本\n\n## v1.5.0\n### 2019/05/28  \n1. 增加小米账号和微软的授权登陆\n2. 发布1.5.0版本\n\n## v1.4.0\n### 2019/05/26 \n1. 增加抖音和Linkedin的授权登陆\n2. 修改部分图片命名\n3. 优化部分代码\n4. 修复`AuthSource`中腾讯云开发平台的拼写错误：`TENCEN_CLOUD`->`TENCENT_CLOUD`\n5. 修复支付宝登陆时用户名为空的问题\n\n## v1.3.3\n### 2019/05/24  \n1. 修复一些问题\n2. 升级api，在AuthUser中增加`uuid`属性，可以通过`uuid` + `source`唯一确定一个用户，此举解决了用户身份归属的问题。\n3. 发布1.3.3版本的jar包到公开仓库（1.3.2忘记发布了，( ╯□╰ )）\n4. 重要：经咨询官方客服得知，CSDN的授权开放平台已经下线，如果以前申请过的应用，可以继续使用，但是不再支持申请新的应用。so, 本项目中的CSDN登录只能针对少部分用户使用了\n\n## v1.3.1\n### 2019/05/23  \n1. 修复QQ登录的问题\n2. 发布1.3.1版本的jar包到公开仓库\n\n## v1.3.0\n### 2019/05/21  \n1. 新增google授权登录\n2. 新增facebook授权登录\n3. 发布1.3.0版本的jar包到公开仓库\n\n## v1.1.0\n### 2019/05/18  \n1. 发布1.1.0版本的jar包到公开仓库（支持qq和微信登录）\n2. 支持淘宝登录\n3. 修改`AuthUser.java`类中的`accessToken`属性，由原本的~~accessToken (String)~~改为`token (AuthToken)`\n4. 修复一些bug\n5. 发布1.2.0版本的jar包到公开仓库（支持淘宝登录）\n\n### 2019/05/17 \n1. 增加qq和微信的授权登录\n2. 修改getAccessToken方法的返回值\n\n## v1.0.1\n### 2019/03/27  \n集成 支付宝授权登录\n\n## v1.0.0\n### 2019/03/25  \n史上最全的整合第三方登录的工具,目前已支持Github、Gitee、微博、钉钉和百度、Coding、腾讯云开发者平台和OSChina登录。 Login, so easy!\n"
  },
  {
    "path": "CODE_OF_CONDUCT.md",
    "content": "# Contributor Covenant Code of Conduct\n\n## Our Pledge\n\nIn the interest of fostering an open and welcoming environment, we as\ncontributors and maintainers pledge to making participation in our project and\nour community a harassment-free experience for everyone, regardless of age, body\nsize, disability, ethnicity, sex characteristics, gender identity and expression,\nlevel of experience, education, socio-economic status, nationality, personal\nappearance, race, religion, or sexual identity and orientation.\n\n## Our Standards\n\nExamples of behavior that contributes to creating a positive environment\ninclude:\n\n* Using welcoming and inclusive language\n* Being respectful of differing viewpoints and experiences\n* Gracefully accepting constructive criticism\n* Focusing on what is best for the community\n* Showing empathy towards other community members\n\nExamples of unacceptable behavior by participants include:\n\n* The use of sexualized language or imagery and unwelcome sexual attention or\n advances\n* Trolling, insulting/derogatory comments, and personal or political attacks\n* Public or private harassment\n* Publishing others' private information, such as a physical or electronic\n address, without explicit permission\n* Other conduct which could reasonably be considered inappropriate in a\n professional setting\n\n## Our Responsibilities\n\nProject maintainers are responsible for clarifying the standards of acceptable\nbehavior and are expected to take appropriate and fair corrective action in\nresponse to any instances of unacceptable behavior.\n\nProject maintainers have the right and responsibility to remove, edit, or\nreject comments, commits, code, wiki edits, issues, and other contributions\nthat are not aligned to this Code of Conduct, or to ban temporarily or\npermanently any contributor for other behaviors that they deem inappropriate,\nthreatening, offensive, or harmful.\n\n## Scope\n\nThis Code of Conduct applies both within project spaces and in public spaces\nwhen an individual is representing the project or its community. Examples of\nrepresenting a project or community include using an official project e-mail\naddress, posting via an official social media account, or acting as an appointed\nrepresentative at an online or offline event. Representation of a project may be\nfurther defined and clarified by project maintainers.\n\n## Enforcement\n\nInstances of abusive, harassing, or otherwise unacceptable behavior may be\nreported by contacting the project team at yadong.zhang0415@gmail.com. All\ncomplaints will be reviewed and investigated and will result in a response that\nis deemed necessary and appropriate to the circumstances. The project team is\nobligated to maintain confidentiality with regard to the reporter of an incident.\nFurther details of specific enforcement policies may be posted separately.\n\nProject maintainers who do not follow or enforce the Code of Conduct in good\nfaith may face temporary or permanent repercussions as determined by other\nmembers of the project's leadership.\n\n## Attribution\n\nThis Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,\navailable at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html\n\n[homepage]: https://www.contributor-covenant.org\n\nFor answers to common questions about this code of conduct, see\nhttps://www.contributor-covenant.org/faq\n"
  },
  {
    "path": "LICENSE",
    "content": "MIT License\n\nCopyright (c) 2019 https://gitee.com/yadong.zhang/JustAuth\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE."
  },
  {
    "path": "README.en-US.md",
    "content": "<p align=\"center\">\n\t<a href=\"https://www.justauth.cn\"><img src=\"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/Justauth.png\" width=\"400\"></a>\n</p>\n<p align=\"center\">\n\t<strong>Login, so easy.</strong>\n</p>\n<p align=\"center\">\n\t<a target=\"_blank\" href=\"https://search.maven.org/search?q=JustAuth\">\n\t\t<img src=\"https://img.shields.io/github/v/release/justauth/JustAuth?style=flat-square\" ></img>\n\t</a>\n\t<a target=\"_blank\" href=\"https://oss.sonatype.org/content/repositories/snapshots/me/zhyd/oauth/JustAuth/\">\n\t\t<img src=\"https://img.shields.io/nexus/s/https/oss.sonatype.org/me.zhyd.oauth/JustAuth.svg?style=flat-square\" ></img>\n\t</a>\n\t<a target=\"_blank\" href=\"https://gitee.com/yadong.zhang/JustAuth/blob/master/LICENSE\">\n\t\t<img src=\"https://img.shields.io/apm/l/vim-mode.svg?color=yellow\" ></img>\n\t</a>\n\t<a target=\"_blank\" href=\"https://www.oracle.com/technetwork/java/javase/downloads/index.html\">\n\t\t<img src=\"https://img.shields.io/badge/JDK-1.8+-green.svg\" ></img>\n\t</a>\n\t<a target=\"_blank\" href=\"https://www.justauth.cn\" title=\"参考文档\">\n\t\t<img src=\"https://img.shields.io/badge/Docs-latest-blueviolet.svg\" ></img>\n\t</a>\n\t<a href=\"https://codecov.io/gh/justauth/JustAuth\">\n\t\t<img src=\"https://codecov.io/gh/justauth/JustAuth/branch/master/graph/badge.svg?token=zYiAqd9aFz\" />\n\t</a>\n\t<a href='https://gitee.com/yadong.zhang/JustAuth/stargazers'>\n\t  <img src='https://gitee.com/yadong.zhang/JustAuth/badge/star.svg?theme=gvp' alt='star'></img>\n\t</a>\n\t<a target=\"_blank\" href='https://github.com/zhangyd-c/JustAuth'>\n\t\t<img src=\"https://img.shields.io/github/stars/zhangyd-c/JustAuth.svg?style=social\" alt=\"github star\"></img>\n\t</a>\n</p>\n\n-------------------------------------------------------------------------------\n<p align=\"center\">\n<img src='./docs/media/75a3c076.png' alt='star'></img>\n</p>\n\n-------------------------------------------------------------------------------\n\n\n\n`JustAuth`, as you see, It is just a Java library of third-party authorized login, It's smaller and easier to use. JustAuth is the best third-party login tool written in JAVA.\n\nSource Code：[gitee](https://gitee.com/yadong.zhang/JustAuth) | [github](https://github.com/zhangyd-c/JustAuth)    \nDocs：[Reference Doc](https://www.justauth.cn)\n\n## Features\n\n1. **Multiple platform**: Has integrated more than a dozen third-party platforms.([plan](https://gitee.com/yadong.zhang/JustAuth/issues/IUGRK))\n2. **Minimalist**: The minimalist design is very simple to use.\n\n## Quick start\n\n### Add maven dependency\n\n- Add JustAuth dependency\n\nThese artifacts are available from Maven Central:\n```xml\n<dependency>\n    <groupId>me.zhyd.oauth</groupId>\n    <artifactId>JustAuth</artifactId>\n  <version>{latest-version}</version>\n</dependency>\n```\n\n> **latest-version** ：\n> - CURRENT: ![](https://img.shields.io/github/v/release/justauth/JustAuth?style=flat-square)\n> - SNAPSHOT: ![](https://img.shields.io/nexus/s/https/oss.sonatype.org/me.zhyd.oauth/JustAuth.svg?style=flat-square)\n\n\n- Add http dependency（Only need one）\n  \n> If there is already in the project, please ignore it. In addition, you need to pay special attention. If the low version of the dependency has been introduced in the project, please exclude the low version of the dependency first, and then introduce the high version or the latest version of the dependency\n\n- hutool-http\n\n  ```xml\n  <dependency>\n      <groupId>cn.hutool</groupId>\n      <artifactId>hutool-http</artifactId>\n      <version>5.2.5</version>\n  </dependency>\n  ```\n\n- httpclient\n\n  ```xml\n  <dependency>\n  \t<groupId>org.apache.httpcomponents</groupId>\n    \t<artifactId>httpclient</artifactId>\n    \t<version>4.5.12</version>\n  </dependency>\n  ```\n\n- okhttp\n\n  ```xml\n  <dependency>\n    <groupId>com.squareup.okhttp3</groupId>\n    <artifactId>okhttp</artifactId>\n    <version>4.4.1</version>\n  </dependency>\n  ```\n\n\n### Using JustAuth API\n\n#### Simple\n\n```java\n// Create authorization request\nAuthRequest authRequest = new AuthGiteeRequest(AuthConfig.builder()\n        .clientId(\"clientId\")\n        .clientSecret(\"clientSecret\")\n        .redirectUri(\"redirectUri\")\n        .build());\n// Generate authorization page url\nauthRequest.authorize(\"state\");\n// Get token and userinfo\nauthRequest.login(callback);\n```\n\n#### Builder 1. Use unchanging `AuthConfig`\n\n```java\n// Create authorization request\nAuthRequest authRequest = AuthRequestBuilder.builder()\n    .source(\"github\")\n    .authConfig(AuthConfig.builder()\n        .clientId(\"clientId\")\n        .clientSecret(\"clientSecret\")\n        .redirectUri(\"redirectUri\")\n        .build())\n    .build();\n```\n\n#### Builder 2. Use dynamic `AuthConfig`\n\n```java\n// Create authorization request\nAuthRequest authRequest = AuthRequestBuilder.builder()\n    .source(\"gitee\")\n    .authConfig((source) -> {\n        // Use source to dynamically get AuthConfig\n        // Here you can flexibly take the configuration from sql or take the configuration from the configuration file\n        return AuthConfig.builder()\n            .clientId(\"clientId\")\n            .clientSecret(\"clientSecret\")\n            .redirectUri(\"redirectUri\")\n            .build();\n    })\n    .build();\n```\n\n#### Builder 3. Support custom platform\n\n```java\nAuthRequest authRequest = AuthRequestBuilder.builder()\n    // Key point: configure the custom implementation of AuthSource\n    .extendSource(AuthExtendSource.values())\n    // Enum name in AuthExtendSource\n    .source(\"other\")\n    // ... Do other things\n    .build();\n```\n\n## Contributions\n\n1. Fork this project to your repository\n2. Clone the project after fork.\n3. Modify the code (either to fix issue, or to add new features)\n4. Commit and push code to a remote repository\n5. Create a new PR (pull request), and select `dev` branch\n6. Waiting for author to merge\n\nI look forward to your joining us.\n\n\n## Contributors\n\n[contributors](https://www.justauth.cn/contributors.html)\n\n## Change Logs\n\n[CHANGELOGS](https://www.justauth.cn/update.html)\n\n## Recommend\n\n- `spring-boot-demo` In-depth study and actual combat of spring boot projects: [https://github.com/xkcoding/spring-boot-demo](https://github.com/xkcoding/spring-boot-demo)\n- `mica` Efficient Development of scaffolding by Spring Cloud: [https://github.com/lets-mica/mica](https://github.com/lets-mica/mica)\n- `pig` Cosmic strongest Micro Services Certified authorized scaffolding (essential for Architects): [https://gitee.com/log4j/pig](https://gitee.com/log4j/pig)\n- `SpringBlade` Complete online solution (necessary for enterprise development): https://gitee.com/smallc/SpringBlade\n\n## References\n\n- [The OAuth 2.0 Authorization Framework](https://tools.ietf.org/html/rfc6749)\n- [OAuth 2.0](https://oauth.net/2/)\n"
  },
  {
    "path": "README.md",
    "content": "<p align=\"center\">\n\t<a href=\"https://www.justauth.cn\"><img src=\"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/Justauth.png\" width=\"400\"></a>\n</p>\n<p align=\"center\">\n\t<strong>Login, so easy.</strong>\n</p>\n<p align=\"center\">\n\t<a target=\"_blank\" href=\"https://search.maven.org/search?q=JustAuth\">\n\t\t<img src=\"https://img.shields.io/github/v/release/justauth/JustAuth?style=flat-square\" ></img>\n\t</a>\n\t<a target=\"_blank\" href=\"https://oss.sonatype.org/content/repositories/snapshots/me/zhyd/oauth/JustAuth/\">\n\t\t<img src=\"https://img.shields.io/nexus/s/https/oss.sonatype.org/me.zhyd.oauth/JustAuth.svg?style=flat-square\" ></img>\n\t</a>\n\t<a target=\"_blank\" href=\"https://gitee.com/yadong.zhang/JustAuth/blob/master/LICENSE\">\n\t\t<img src=\"https://img.shields.io/apm/l/vim-mode.svg?color=yellow\" ></img>\n\t</a>\n\t<a target=\"_blank\" href=\"https://www.oracle.com/technetwork/java/javase/downloads/index.html\">\n\t\t<img src=\"https://img.shields.io/badge/JDK-1.8+-green.svg\" ></img>\n\t</a>\n\t<a target=\"_blank\" href=\"https://www.justauth.cn\" title=\"参考文档\">\n\t\t<img src=\"https://img.shields.io/badge/Docs-latest-blueviolet.svg\" ></img>\n\t</a>\n\t<a href=\"https://codecov.io/gh/justauth/JustAuth\">\n\t\t<img src=\"https://codecov.io/gh/justauth/JustAuth/branch/master/graph/badge.svg?token=zYiAqd9aFz\" />\n\t</a>\n\t<a href='https://gitee.com/yadong.zhang/JustAuth/stargazers'>\n\t  <img src='https://gitee.com/yadong.zhang/JustAuth/badge/star.svg?theme=gvp' alt='star'></img>\n\t</a>\n\t<a target=\"_blank\" href='https://github.com/zhangyd-c/JustAuth'>\n\t\t<img src=\"https://img.shields.io/github/stars/zhangyd-c/JustAuth.svg?style=social\" alt=\"github star\"></img>\n\t</a>\n</p>\n\n-------------------------------------------------------------------------------\n<p align=\"center\">\n<img src='./docs/media/75a3c076.png' alt='star'></img>\n</p>\n\n-------------------------------------------------------------------------------\n\nQQ 群：230017570    \n微信群：justauth （备注`justauth`或者`ja`）    \n帮助文档：[www.justauth.cn](https://www.justauth.cn)    \n\n## 什么是 JustAuth？\n\nJustAuth，如你所见，它仅仅是一个**第三方授权登录**的**工具类库**，它可以让我们脱离繁琐的第三方登录 SDK，让登录变得**So easy!**\n\nJustAuth 集成了诸如：Github、Gitee、支付宝、新浪微博、微信、Google、Facebook、Twitter、StackOverflow等国内外数十家第三方平台。更多请参考<a href=\"https://www.justauth.cn\" target=\"_blank\">已集成的平台</a>\n\n## 有哪些特点？\n\n1. **全**：已集成十多家第三方平台（国内外常用的基本都已包含），仍然还在持续扩展中（[开发计划](https://gitee.com/yadong.zhang/JustAuth/issues/IUGRK)）！\n2. **简**：API就是奔着最简单去设计的（见后面`快速开始`），尽量让您用起来没有障碍感！\n\n## 有哪些功能？\n\n- 集成国内外数十家第三方平台，实现快速接入。<a href=\"https://www.justauth.cn/guide/\" target=\"_blank\">参考文档</a>\n- 自定义 State 缓存，支持各种分布式缓存组件。<a href=\"https://www.justauth.cn/features/using-state/\" target=\"_blank\">参考文档</a>\n- 自定义 OAuth 平台，更容易适配自有的 OAuth 服务。<a href=\"https://www.justauth.cn/features/customize-the-oauth/\" target=\"_blank\">参考文档</a>\n- 自定义 Http 实现，选择权完全交给开发者，不会单独依赖某一具体实现。<a href=\"https://www.justauth.cn/guide/quickstart/how-to-use/#%E4%BD%BF%E7%94%A8%E6%AD%A5%E9%AA%A4\" target=\"_blank\">参考文档</a>\n- 自定义 Scope，支持更完善的授权体系。<a href=\"https://www.justauth.cn/features/customize-scopes/#%E5%85%B3%E4%BA%8E-scope\" target=\"_blank\">参考文档</a>\n- 更多...<a href=\"https://www.justauth.cn\" target=\"_blank\">参考文档</a>\n\n## 快速开始\n\n### 引入依赖\n```xml\n<dependency>\n    <groupId>me.zhyd.oauth</groupId>\n    <artifactId>JustAuth</artifactId>\n    <version>{latest-version}</version>\n</dependency>\n```\n\n> **latest-version** 可选：\n> - 稳定版：![](https://img.shields.io/github/v/release/justauth/JustAuth?style=flat-square) \n> - 快照版：![](https://img.shields.io/nexus/s/https/oss.sonatype.org/me.zhyd.oauth/JustAuth.svg?style=flat-square)\n> > 注意：快照版本是功能的尝鲜，并不保证稳定性。请勿在生产环境中使用。\n>\n> <details>\n>   <summary>如何引入快照版本</summary>\n>\n> JustAuth 的快照版本托管在 ossrh 上，所以要指定下载地址。\n> \n> ```xml\n> <repositories>\n>     <repository>\n>         <id>ossrh-snapshot</id>\n>         <url>https://oss.sonatype.org/content/repositories/snapshots</url>\n>         <snapshots>\n>             <enabled>true</enabled>\n>         </snapshots>\n>     </repository>\n> </repositories>\n> ```\n> \n> 如果你想第一时间获取 JustAuth 的最新快照，可以添加下列代码，每次构建时都检查是否有最新的快照（默认每天检查）。\n> \n> ```diff\n>        <url>https://oss.sonatype.org/content/repositories/snapshots</url>\n>         <snapshots>\n> +           <updatePolicy>always</updatePolicy>\n>             <enabled>true</enabled>\n>         </snapshots>\n> ```\n> \n> </details>\n\n如下**任选一种** HTTP 工具 依赖，_项目内如果已有，请忽略。另外需要特别注意，如果项目中已经引入了低版本的依赖，请先排除低版本依赖后，再引入高版本或者最新版本的依赖_\n\n- hutool-http\n\n  ```xml\n  <dependency>\n      <groupId>cn.hutool</groupId>\n      <artifactId>hutool-http</artifactId>\n      <version>5.7.7</version>\n  </dependency>\n  ```\n\n- httpclient\n\n  ```xml\n  <dependency>\n  \t<groupId>org.apache.httpcomponents</groupId>\n    \t<artifactId>httpclient</artifactId>\n    \t<version>4.5.13</version>\n  </dependency>\n  ```\n\n- okhttp\n\n  ```xml\n  <dependency>\n    <groupId>com.squareup.okhttp3</groupId>\n    <artifactId>okhttp</artifactId>\n    <version>4.9.1</version>\n  </dependency>\n  ```\n  \n### 调用api\n\n#### 普通方式\n\n```java\n// 创建授权request\nAuthRequest authRequest = new AuthGiteeRequest(AuthConfig.builder()\n        .clientId(\"clientId\")\n        .clientSecret(\"clientSecret\")\n        .redirectUri(\"redirectUri\")\n        .build());\n// 生成授权页面\nauthRequest.authorize(\"state\");\n// 授权登录后会返回code（auth_code（仅限支付宝））、state，1.8.0版本后，可以用AuthCallback类作为回调接口的参数\n// 注：JustAuth默认保存state的时效为3分钟，3分钟内未使用则会自动清除过期的state\nauthRequest.login(callback);\n```\n\n#### Builder 方式一\n\n静态配置 `AuthConfig`\n\n```java\nAuthRequest authRequest = AuthRequestBuilder.builder()\n    .source(\"github\")\n    .authConfig(AuthConfig.builder()\n        .clientId(\"clientId\")\n        .clientSecret(\"clientSecret\")\n        .redirectUri(\"redirectUri\")\n        .build())\n    .build();\n// 生成授权页面\n  authRequest.authorize(\"state\");\n// 授权登录后会返回code（auth_code（仅限支付宝））、state，1.8.0版本后，可以用AuthCallback类作为回调接口的参数\n// 注：JustAuth默认保存state的时效为3分钟，3分钟内未使用则会自动清除过期的state\n  authRequest.login(callback);\n```\n\n#### Builder 方式二\n\n动态获取并配置 `AuthConfig`\n\n```java\nAuthRequest authRequest = AuthRequestBuilder.builder()\n    .source(\"gitee\")\n    .authConfig((source) -> {\n        // 通过 source 动态获取 AuthConfig\n        // 此处可以灵活的从 sql 中取配置也可以从配置文件中取配置\n        return AuthConfig.builder()\n            .clientId(\"clientId\")\n            .clientSecret(\"clientSecret\")\n            .redirectUri(\"redirectUri\")\n            .build();\n    })\n    .build();\nAssert.assertTrue(authRequest instanceof AuthGiteeRequest);\nSystem.out.println(authRequest.authorize(AuthStateUtils.createState()));\n```\n\n#### Builder 方式支持自定义的平台\n\n```java\nAuthRequest authRequest = AuthRequestBuilder.builder()\n    // 关键点：将自定义实现的 AuthSource 配置上\n    .extendSource(AuthExtendSource.values())\n    // source 对应 AuthExtendSource 中的枚举 name\n    .source(\"other\")\n    // ... 其他内容不变，参考上面的示例\n    .build();\n```\n\n## 赞助和支持\n\n感谢以下赞助商的支持：\n\n[我要赞助](https://www.justauth.cn/sponsor.html)\n\n## JustAuth 的用户\n有很多公司、组织和个人把 JustAuth 用于学习、研究、生产环境和商业产品中，包括（但不限于）：\n\n[![](docs/users/col.png)](https://www.mochiwang.com \"给作者提供云写作的一个工具\")![](docs/users/bjgyol.png)![](docs/users/foresealife.png)![](docs/users/sevnce.png)\n\n![](docs/users/bladex.png)![](docs/users/gun.png)![](docs/users/sika.jpg)![](docs/users/maxkey.png)![](docs/users/shiroaction.png)![](docs/users/xkcoding.png)\n\n\n\n怎么没有我？[登记](https://gitee.com/yadong.zhang/JustAuth/issues/IZ2T7)\n\n## 开源推荐\n\n- `JAP` 开源的登录认证中间件: [https://gitee.com/fujieid/jap](https://gitee.com/fujieid/jap)\n- `spring-boot-demo` 深度学习并实战 spring boot 的项目: [https://github.com/xkcoding/spring-boot-demo](https://github.com/xkcoding/spring-boot-demo)\n- `mica` SpringBoot 微服务高效开发工具集: [https://github.com/lets-mica/mica](https://github.com/lets-mica/mica)\n- `sureness` 面向restful api的高性能认证鉴权框架：[sureness](https://github.com/usthe/sureness)\n  \n更多推荐，请参考：[JustAuth - 开源推荐](https://www.justauth.cn)\n\n## 鸣谢\n\n- 感谢 JetBrains 提供的免费开源 License：\n\n<p>\n<img src=\"https://images.gitee.com/uploads/images/2020/0406/220236_f5275c90_5531506.png\" alt=\"图片引用自lets-mica\" style=\"float:left;\">\n</p>\n\n## 其他\n\n- [CONTRIBUTORS](https://www.justauth.cn/contributors.html)\n- [CHANGELOGS](https://www.justauth.cn/update.html)\n- [PLAN](https://gitee.com/yadong.zhang/JustAuth/issues/IUGRK)\n\n## 贡献者列表\n\n[![contributors](https://whnb.wang/contributors/yadong.zhang/JustAuth)](https://whnb.wang)\n\n## Stars 趋势\n\n### Gitee\n\n[![Stargazers over time](https://whnb.wang/img/yadong.zhang/JustAuth?e=604800)](https://whnb.wang/yadong.zhang/JustAuth?e=604800)\n\n### Github\n\n[![Stargazers over time](https://starchart.cc/justauth/JustAuth.svg)](https://starchart.cc/justauth/JustAuth)\n\n### ProductHunt\n\n<a href=\"https://www.producthunt.com/posts/justauth?utm_source=badge-featured&utm_medium=badge&utm_souce=badge-justauth\" target=\"_blank\"><img src=\"https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=196886&theme=dark\" alt=\"JustAuth - Login, so easy! | Product Hunt Embed\" style=\"width: 250px; height: 54px;\" width=\"250px\" height=\"54px\" /></a>\n"
  },
  {
    "path": "bin/pull-dev.sh",
    "content": "git pull origin dev && git pull github dev\n"
  },
  {
    "path": "bin/pull.sh",
    "content": "git pull origin master && git pull github master\n"
  },
  {
    "path": "bin/push-dev.sh",
    "content": "git push origin dev && git push github dev\n"
  },
  {
    "path": "bin/push.sh",
    "content": "git push origin master && git push github master\n"
  },
  {
    "path": "bin/repVersion.sh",
    "content": "#!/bin/bash\n\n#-----------------------------------------------------------\n# 参考自 hutool 工具\n# 此脚本用于每次升级justauth时替换相应位置的版本号\n#-----------------------------------------------------------\npwd=$(pwd)\necho \"当前路径：$pwd\"\n\nif [ -n \"$1\" ];then\n    new_version=\"$1\"\n    old_version=`cat $pwd/bin/version.txt`\n    echo \"$old_version 替换为新版本 $new_version\"\nelse\n    # 参数错误，退出\n    echo \"ERROR: 请指定新版本！\"\n    exit\nfi\n\nif [ ! -n \"$old_version\" ]; then\n    echo \"ERROR: 旧版本不存在，请确认bin/version.txt中信息正确\"\n    exit\nfi\n\n# 替换README.md等文件中的版本\nsed -i \"s/${old_version}/${new_version}/g\" $pwd/README.md\nsed -i \"s/${old_version}/${new_version}/g\" $pwd/README.en-US.md\n\n# 替换pom.xml中的版本\nsed -i \"s/${old_version}/${new_version}/g\" $pwd/pom.xml\n\n# 保留新版本号\necho \"$new_version\" > $pwd/bin/version.txt\n"
  },
  {
    "path": "bin/updVersion.sh",
    "content": "#!/bin/bash\n\n#------------------------------------------------\n# 参考自 hutool 工具\n# 升级justauth版本，包括：\n# 1. 升级pom.xml中的版本号\n# 2. 替换README.md中的版本号\n#------------------------------------------------\n\nif [ ! -n \"$1\" ]; then\n        echo \"ERROR: 新版本不存在，请指定参数1\"\n        exit\nfi\n\n# 替换所有模块pom.xml中的版本\nmvn versions:set -DnewVersion=$1\n\n# 替换其它地方的版本\nsource $(pwd)/bin/repVersion.sh \"$1\"\n"
  },
  {
    "path": "bin/version.txt",
    "content": "1.16.7\n"
  },
  {
    "path": "docs/.nojekyll",
    "content": ""
  },
  {
    "path": "docs/index.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n  <meta name=\"google-site-verification\" content=\"DJSx-fAGWci-EWueWy2_RfafHJX1iv5XhfftGSg-SR0\" />\n  <meta charset=\"UTF-8\">\n  <title>JustAuth - 史上最全的整合第三方登录的开源库</title>\n  <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\" />\n  <meta name=\"viewport\" content=\"width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0\">\n\n  <meta name=\"description\" content=\"JustAuth，史上最全的整合第三方登录的开源库\" />\n  <meta name=\"keywords\" content=\"JustAuth,第三方授权登录,OAuth\" />\n\n  <meta itemprop=\"name\" content=\"JustAuth,史上最全的整合第三方登录的开源库\" />\n  <meta itemprop=\"description\" content=\"JustAuth，如你所见，它仅仅是一个第三方授权登录的工具类库，它可以让我们脱离繁琐的第三方登录SDK，让登录变得So easy!\" />\n\n</head>\n<body>\n  <script>\n    window.location.href = \"https://www.justauth.cn\";\n  </script>\n</body>\n</html>\n"
  },
  {
    "path": "example.md",
    "content": "## 各平台授权页面示例\n\n_注：非全部平台，部分平台可能不存在图例_\n\n#### 授权gitee\n\n![Gitee授权登录](https://images.gitee.com/uploads/images/2019/0221/140015_4c09610e_784199.png \"Gitee授权登录\")\n\n#### 授权github\n\n![Github授权登录](https://images.gitee.com/uploads/images/2019/0221/140032_58f7dfb5_784199.png \"Github授权登录\")\n\n#### 授权weibo\n\n![微博授权登录](https://images.gitee.com/uploads/images/2019/0222/191210_67d5597c_784199.png \"微博授权登录\")\n\n#### 授权钉钉\n\n![钉钉授权登录](https://images.gitee.com/uploads/images/2019/0221/140540_8da8d959_784199.jpeg \"钉钉授权登录\")\n\n#### 授权百度\n\n![百度授权登录](https://images.gitee.com/uploads/images/2019/0221/140607_ebf1dcb6_784199.png \"百度授权登录\")\n\n#### 授权coding\n\n![Coding授权登录](https://images.gitee.com/uploads/images/2019/0224/192106_fd53b3d7_784199.png \"Coding授权登录\")\n\n#### 授权腾讯云开发者平台\n\n![腾讯云开发者平台授权登录](https://images.gitee.com/uploads/images/2019/0224/192128_db9e203b_784199.png \"腾讯云开发者平台授权登录\")\n\n#### 授权oschina\n\n![授权oschina登录](https://images.gitee.com/uploads/images/2019/0322/230652_05b4fd8a_784199.png \"授权oschina\")\n\n#### 授权支付宝\n\n![授权支付宝登录](https://images.gitee.com/uploads/images/2019/0327/183654_3d4b94eb_784199.png \"授权支付宝登录\")\n\n#### 授权qq\n\n暂无\n\n#### 授权微信\n\n![授权微信登录](https://images.gitee.com/uploads/images/2019/0523/104955_d4cea750_784199.png \"授权微信登录\")\n\n#### 授权淘宝\n\n![授权淘宝登录](https://images.gitee.com/uploads/images/2019/0518/154604_68b38305_784199.png \"授权淘宝登录\")\n\n\n#### 授权Google\n\n![授权google登录](https://images.gitee.com/uploads/images/2019/0521/190650_85c5f1c7_784199.png \"授权google登录\")\n\n#### 授权Facebook\n\n![授权facebook登录](https://images.gitee.com/uploads/images/2019/0521/233647_6a89fb45_784199.png \"授权facebook登录\")\n\n#### 授权抖音\n\n暂无\n\n#### 授权领英\n\n![授权领英登录](https://images.gitee.com/uploads/images/2019/0527/152207_a6342979_784199.png \"授权领英登录\")\n\n\n#### 授权微软\n\n![授权微软](https://images.gitee.com/uploads/images/2019/0718/224146_681aa535_784199.png \"授权微软\")\n\n#### 授权小米\n\n暂无\n\n#### 授权今日头条\n\n暂无\n\n#### 授权Teambition\n\n![授权Teambition](https://images.gitee.com/uploads/images/2019/0718/224119_3da514ab_784199.png \"授权Teambition\")\n\n#### 授权Pinterest\n\n![授权Pinterest](https://images.gitee.com/uploads/images/2019/0718/155012_6290f500_784199.jpeg \"授权Pinterest\")\n\n#### 授权Renren\n\n![授权Renre](https://images.gitee.com/uploads/images/2019/0718/155035_8e26c10a_784199.jpeg \"授权Renren\")\n\n#### 授权Stack Overflow\n\n![授权Stack Overflow](https://images.gitee.com/uploads/images/2019/0718/192639_cc301ba7_784199.png \"授权Stack Overflow\")\n\n#### 授权afdian\n\n![授权afdian](https://img.fastmirror.net/s/2023/03/24/641d63a8c19b5.png \"授权afDian\")\n\n#### 授权Twitter\n\n![授权Twitter]( \"授权Twitter\")\n\n#### 授权csdn\n\n暂无\n\n_请知悉：经咨询CSDN官方客服得知，CSDN的授权开放平台已经下线。如果以前申请过的应用，可以继续使用，但是不再支持申请新的应用。so, 本项目中的CSDN登录只能针对少部分用户使用了_\n"
  },
  {
    "path": "ja.sh",
    "content": "#!/bin/bash\n\n# 参考自 hutool 工具\nhelp(){\n  echo \"--------------------------------------------------------------------------\"\n  echo \"\"\n  echo \"usage: ./ja.sh [updv]\"\n  echo \"\"\n  echo \"-updv [version num]   Update all justauth related versions.\"\n  echo \"\"\n  echo \"--------------------------------------------------------------------------\"\n}\n\ncase \"$1\" in\n  'updv')\n    bin/updVersion.sh $2\n\t;;\n  'ppd')\n    bin/pull-dev.sh\n\t;;\n  'pp')\n    bin/pull.sh\n\t;;\n  'pd')\n    bin/push-dev.sh\n\t;;\n  'p')\n    bin/push.sh\n\t;;\n  'd')\n    bin/deploy.sh\n\t;;\n  *)\n    help\nesac\n"
  },
  {
    "path": "pom.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://maven.apache.org/POM/4.0.0\"\n         xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">\n  <modelVersion>4.0.0</modelVersion>\n\n  <groupId>me.zhyd.oauth</groupId>\n  <artifactId>JustAuth</artifactId>\n  <version>1.16.7</version>\n\n  <name>JustAuth</name>\n  <url>https://gitee.com/yadong.zhang/JustAuth</url>\n  <description>\n    小而全而美的第三方登录开源组件。目前已支持Github、Gitee、微博、钉钉、百度、Coding、腾讯云开发者平台、OSChina、支付宝、QQ、微信、淘宝、Google、Facebook、抖音、领英、小米、微软、今日头条、Teambition、StackOverflow、Pinterest、人人、华为、企业微信、酷家乐、Gitlab、美团、饿了么、推特、飞书、京东、阿里云、喜马拉雅、Amazon、Slack和Line等第三方平台的授权登录。 Login, so easy!\n  </description>\n\n  <licenses>\n    <license>\n      <name>MIT</name>\n      <url>https://gitee.com/yadong.zhang/JustAuth/blob/master/LICENSE</url>\n    </license>\n  </licenses>\n\n  <scm>\n    <connection>scm:git:https://gitee.com/yadong.zhang/JustAuth.git</connection>\n    <developerConnection>scm:git:https://gitee.com/yadong.zhang/JustAuth.git</developerConnection>\n    <url>https://gitee.com/yadong.zhang/JustAuth</url>\n  </scm>\n\n  <developers>\n    <developer>\n      <name>Yadong.Zhang</name>\n      <email>yadong.zhang0415@gmail.com</email>\n      <url>https://www.zhyd.me</url>\n    </developer>\n    <developer>\n      <name>Yangkai.Shen</name>\n      <email>shenyangkai1994@gmail.com</email>\n      <url>https://xkcoding.com</url>\n    </developer>\n    <developer>\n      <name>Hongwei.Peng</name>\n      <email>pengisgood@gmail.com</email>\n      <url>https://github.com/pengisgood</url>\n    </developer>\n  </developers>\n\n  <properties>\n    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\n    <java.version>1.8</java.version>\n    <maven.compiler.source>1.8</maven.compiler.source>\n    <maven.compiler.target>1.8</maven.compiler.target>\n    <maven-source.version>2.2.1</maven-source.version>\n    <maven-compiler.version>3.8.1</maven-compiler.version>\n    <maven-javadoc.version>2.9.1</maven-javadoc.version>\n    <cobertura-version>2.7</cobertura-version>\n    <maven-surefire-version>2.20</maven-surefire-version>\n    <maven-gpg-version>1.6</maven-gpg-version>\n    <maven.test.skip>false</maven.test.skip>\n    <simple-http.version>1.0.5</simple-http.version>\n    <lombok-version>1.18.30</lombok-version>\n    <junit-version>4.13.2</junit-version>\n    <fastjson-version>1.2.83</fastjson-version>\n    <alipay-sdk-version>4.39.165.ALL</alipay-sdk-version>\n    <jacoco-version>0.8.2</jacoco-version>\n    <jwt.version>0.12.3</jwt.version>\n    <bcpkix-jdk18on.version>1.78</bcpkix-jdk18on.version>\n  </properties>\n\n  <dependencies>\n    <dependency>\n      <groupId>org.projectlombok</groupId>\n      <artifactId>lombok</artifactId>\n      <version>${lombok-version}</version>\n      <optional>true</optional>\n    </dependency>\n    <dependency>\n      <groupId>com.xkcoding.http</groupId>\n      <artifactId>simple-http</artifactId>\n      <version>${simple-http.version}</version>\n    </dependency>\n    <dependency>\n      <groupId>junit</groupId>\n      <artifactId>junit</artifactId>\n      <version>${junit-version}</version>\n      <scope>test</scope>\n    </dependency>\n    <dependency>\n      <groupId>com.alibaba</groupId>\n      <artifactId>fastjson</artifactId>\n      <version>${fastjson-version}</version>\n    </dependency>\n    <dependency>\n      <groupId>com.alipay.sdk</groupId>\n      <artifactId>alipay-sdk-java</artifactId>\n      <version>${alipay-sdk-version}</version>\n      <scope>provided</scope>\n      <exclusions>\n        <exclusion>\n          <artifactId>fastjson</artifactId>\n          <groupId>com.alibaba</groupId>\n        </exclusion>\n      </exclusions>\n    </dependency>\n    <dependency>\n      <groupId>io.jsonwebtoken</groupId>\n      <artifactId>jjwt-api</artifactId>\n      <version>${jwt.version}</version>\n      <scope>provided</scope>\n    </dependency>\n    <dependency>\n      <groupId>io.jsonwebtoken</groupId>\n      <artifactId>jjwt-impl</artifactId>\n      <version>${jwt.version}</version>\n      <scope>provided</scope>\n    </dependency>\n    <dependency>\n      <groupId>io.jsonwebtoken</groupId>\n      <artifactId>jjwt-jackson</artifactId>\n      <version>${jwt.version}</version>\n      <scope>provided</scope>\n    </dependency>\n    <dependency>\n      <groupId>org.bouncycastle</groupId>\n      <artifactId>bcpkix-jdk18on</artifactId>\n      <version>${bcpkix-jdk18on.version}</version>\n      <scope>provided</scope>\n    </dependency>\n  </dependencies>\n\n  <build>\n    <finalName>${project.artifactId}-${project.version}</finalName>\n    <plugins>\n      <plugin>\n        <groupId>org.apache.maven.plugins</groupId>\n        <artifactId>maven-compiler-plugin</artifactId>\n        <version>${maven-compiler.version}</version>\n        <configuration>\n          <encoding>${project.build.sourceEncoding}</encoding>\n          <source>${java.version}</source>\n          <target>${java.version}</target>\n        </configuration>\n      </plugin>\n      <plugin>\n        <groupId>org.apache.maven.plugins</groupId>\n        <artifactId>maven-source-plugin</artifactId>\n        <version>${maven-source.version}</version>\n        <inherited>true</inherited>\n        <executions>\n          <execution>\n            <phase>package</phase>\n            <goals>\n              <goal>jar-no-fork</goal>\n            </goals>\n          </execution>\n        </executions>\n      </plugin>\n      <plugin>\n        <groupId>org.apache.maven.plugins</groupId>\n        <artifactId>maven-javadoc-plugin</artifactId>\n        <version>${maven-javadoc.version}</version>\n        <executions>\n          <execution>\n            <phase>package</phase>\n            <goals>\n              <goal>jar</goal>\n            </goals>\n          </execution>\n        </executions>\n        <configuration>\n            <additionalparam>${javadoc.opts}</additionalparam>\n        </configuration>\n      </plugin>\n      <plugin>\n        <groupId>org.apache.maven.plugins</groupId>\n        <artifactId>maven-surefire-plugin</artifactId>\n        <version>${maven-surefire-version}</version>\n        <configuration>\n          <!-- 包含其他测试类 -->\n          <includes>\n            <include>**/*Test.java</include>\n          </includes>\n          <!-- 排除掉AuthRequestTest测试类，该类只做api演示用 -->\n          <excludes>\n            <exclude>**/AuthRequestTest.java</exclude>\n          </excludes>\n        </configuration>\n      </plugin>\n    </plugins>\n  </build>\n  <profiles>\n    <profile>\n      <id>snapshot</id>\n      <distributionManagement>\n        <snapshotRepository>\n          <id>ossrh</id>\n          <url>https://oss.sonatype.org/content/repositories/snapshots</url>\n        </snapshotRepository>\n      </distributionManagement>\n    </profile>\n    <profile>\n      <id>release</id>\n      <build>\n        <plugins>\n            <plugin>\n              <groupId>org.apache.maven.plugins</groupId>\n              <artifactId>maven-source-plugin</artifactId>\n              <version>${maven-source.version}</version>\n              <inherited>true</inherited>\n              <executions>\n                <execution>\n                  <phase>package</phase>\n                  <goals>\n                    <goal>jar-no-fork</goal>\n                  </goals>\n                </execution>\n              </executions>\n            </plugin>\n            <plugin>\n              <groupId>org.codehaus.mojo</groupId>\n              <artifactId>cobertura-maven-plugin</artifactId>\n              <version>${cobertura-version}</version>\n              <configuration>\n                <formats>\n                  <format>html</format>\n                  <format>xml</format>\n                </formats>\n                <check/>\n              </configuration>\n            </plugin>\n            <plugin>\n              <groupId>org.jacoco</groupId>\n              <artifactId>jacoco-maven-plugin</artifactId>\n              <version>${jacoco-version}</version>\n              <executions>\n                <execution>\n                  <goals>\n                    <goal>prepare-agent</goal>\n                  </goals>\n                </execution>\n                <execution>\n                  <id>report</id>\n                  <phase>test</phase>\n                  <goals>\n                    <goal>report</goal>\n                  </goals>\n                </execution>\n              </executions>\n            </plugin>\n            <plugin>\n              <groupId>org.apache.maven.plugins</groupId>\n              <artifactId>maven-gpg-plugin</artifactId>\n              <version>${maven-gpg-version}</version>\n              <executions>\n                <execution>\n                  <phase>verify</phase>\n                  <goals>\n                    <goal>sign</goal>\n                  </goals>\n                </execution>\n              </executions>\n            </plugin>\n          </plugins>\n      </build>\n      <distributionManagement>\n        <repository>\n          <id>sonatype-nexus-staging</id>\n          <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>\n        </repository>\n      </distributionManagement>\n    </profile>\n    <!--私服-->\n    <profile>\n      <id>nexus</id>\n      <build>\n        <plugins>\n            <plugin>\n              <groupId>org.apache.maven.plugins</groupId>\n              <artifactId>maven-gpg-plugin</artifactId>\n              <version>${maven-gpg-version}</version>\n              <executions>\n                <execution>\n                  <phase>verify</phase>\n                  <goals>\n                    <goal>sign</goal>\n                  </goals>\n                </execution>\n              </executions>\n            </plugin>\n          </plugins>\n      </build>\n      <distributionManagement>\n        <repository>\n          <id>xkcoding-nexus</id>\n          <url>https://nexus.xkcoding.com/repository/maven-releases/</url>\n        </repository>\n        <snapshotRepository>\n          <id>xkcoding-nexus</id>\n          <url>https://nexus.xkcoding.com/repository/maven-snapshots/</url>\n        </snapshotRepository>\n      </distributionManagement>\n    </profile>\n    <!-- 禁用 Javadoc 注释检查 -->\n    <profile>\n        <id>disable-javadoc-doclint</id>\n        <activation>\n            <jdk>[1.8,)</jdk>\n        </activation>\n        <properties>\n            <javadoc.opts>-Xdoclint:none</javadoc.opts>\n        </properties>\n    </profile>\n  </profiles>\n</project>\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/AuthRequestBuilder.java",
    "content": "package me.zhyd.oauth;\n\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.config.AuthSource;\nimport me.zhyd.oauth.enums.AuthResponseStatus;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.request.AuthDefaultRequest;\nimport me.zhyd.oauth.request.AuthRequest;\nimport me.zhyd.oauth.utils.StringUtils;\n\nimport java.util.Arrays;\nimport java.util.function.Function;\n\n/**\n * 快捷的构建 AuthRequest\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @author ngcly\n * @version 1.0.0\n * @since 1.16.3\n */\npublic class AuthRequestBuilder {\n    private String source;\n    private AuthConfig authConfig;\n    private AuthStateCache authStateCache;\n    private AuthSource[] extendSource;\n\n    private AuthRequestBuilder() {\n\n    }\n\n    public static AuthRequestBuilder builder() {\n        return new AuthRequestBuilder();\n    }\n\n    public AuthRequestBuilder source(String source) {\n        this.source = source;\n        return this;\n    }\n\n    public AuthRequestBuilder authConfig(AuthConfig authConfig) {\n        this.authConfig = authConfig;\n        return this;\n    }\n\n    public AuthRequestBuilder authConfig(Function<String, AuthConfig> authConfig) {\n        this.authConfig = authConfig.apply(this.source);\n        return this;\n    }\n\n    public AuthRequestBuilder authStateCache(AuthStateCache authStateCache) {\n        this.authStateCache = authStateCache;\n        return this;\n    }\n\n    public AuthRequestBuilder extendSource(AuthSource... extendSource) {\n        this.extendSource = extendSource;\n        return this;\n    }\n\n    public AuthRequest build() {\n        if (StringUtils.isEmpty(this.source) || null == this.authConfig) {\n            throw new AuthException(AuthResponseStatus.NOT_IMPLEMENTED);\n        }\n        // 合并 JustAuth 默认的 AuthDefaultSource 和 开发者自定义的 AuthSource\n        AuthSource[] sources = this.concat(AuthDefaultSource.values(), extendSource);\n        // 筛选符合条件的 AuthSource\n        AuthSource source = Arrays.stream(sources).distinct()\n            .filter(authSource -> authSource.getName().equalsIgnoreCase(this.source))\n            .findAny()\n            .orElseThrow(() -> new AuthException(AuthResponseStatus.NOT_IMPLEMENTED));\n\n        Class<? extends AuthDefaultRequest> targetClass = source.getTargetClass();\n        if (null == targetClass) {\n            throw new AuthException(AuthResponseStatus.NOT_IMPLEMENTED);\n        }\n        try {\n            if (this.authStateCache == null) {\n                return targetClass.getDeclaredConstructor(AuthConfig.class).newInstance(this.authConfig);\n            } else {\n                return targetClass.getDeclaredConstructor(AuthConfig.class, AuthStateCache.class).newInstance(this.authConfig, this.authStateCache);\n            }\n        } catch (Exception e) {\n            e.printStackTrace();\n            throw new AuthException(AuthResponseStatus.NOT_IMPLEMENTED);\n        }\n    }\n\n    private AuthSource[] concat(AuthSource[] first, AuthSource[] second) {\n        if (null == second || second.length == 0) {\n            return first;\n        }\n        AuthSource[] result = new AuthSource[first.length + second.length];\n        System.arraycopy(first, 0, result, 0, first.length);\n        System.arraycopy(second, 0, result, first.length, second.length);\n        return result;\n    }\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/cache/AuthCache.java",
    "content": "package me.zhyd.oauth.cache;\n\n/**\n * JustAuth缓存，用来缓存State\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.9.3\n */\npublic interface AuthCache {\n\n    /**\n     * 设置缓存\n     *\n     * @param key   缓存KEY\n     * @param value 缓存内容\n     */\n    void set(String key, String value);\n\n    /**\n     * 设置缓存，指定过期时间\n     *\n     * @param key     缓存KEY\n     * @param value   缓存内容\n     * @param timeout 指定缓存过期时间（毫秒）\n     */\n    void set(String key, String value, long timeout);\n\n    /**\n     * 获取缓存\n     *\n     * @param key 缓存KEY\n     * @return 缓存内容\n     */\n    String get(String key);\n\n    /**\n     * 是否存在key，如果对应key的value值已过期，也返回false\n     *\n     * @param key 缓存KEY\n     * @return true：存在key，并且value没过期；false：key不存在或者已过期\n     */\n    boolean containsKey(String key);\n\n    /**\n     * 清理过期的缓存\n     */\n    default void pruneCache() {\n    }\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/cache/AuthCacheConfig.java",
    "content": "package me.zhyd.oauth.cache;\n\n/**\n * AuthCache配置类\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.10.0\n */\npublic class AuthCacheConfig {\n\n    /**\n     * 默认缓存过期时间：3分钟\n     * 鉴于授权过程中，根据个人的操作习惯，或者授权平台的不同（google等），每个授权流程的耗时也有差异，不过单个授权流程一般不会太长\n     * 本缓存工具默认的过期时间设置为3分钟，即程序默认认为3分钟内的授权有效，超过3分钟则默认失效，失效后删除\n     */\n    public static long timeout = 3 * 60 * 1000;\n\n    /**\n     * 是否开启定时{@link AuthDefaultCache#pruneCache()}的任务\n     */\n    public static boolean schedulePrune = true;\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/cache/AuthCacheScheduler.java",
    "content": "package me.zhyd.oauth.cache;\n\nimport java.util.concurrent.ScheduledExecutorService;\nimport java.util.concurrent.ScheduledThreadPoolExecutor;\nimport java.util.concurrent.TimeUnit;\nimport java.util.concurrent.atomic.AtomicInteger;\n\n/**\n * 缓存调度器\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.9.3\n */\npublic enum AuthCacheScheduler {\n\n    /**\n     * 当前实例\n     */\n    INSTANCE;\n\n    private AtomicInteger cacheTaskNumber = new AtomicInteger(1);\n    private ScheduledExecutorService scheduler;\n\n    AuthCacheScheduler() {\n        create();\n    }\n\n    private void create() {\n        this.shutdown();\n        this.scheduler = new ScheduledThreadPoolExecutor(10, r -> new Thread(r, String.format(\"JustAuth-Task-%s\", cacheTaskNumber.getAndIncrement())));\n    }\n\n    public void shutdown() {\n        if (null != scheduler) {\n            this.scheduler.shutdown();\n        }\n    }\n\n    public void schedule(Runnable task, long delay) {\n        this.scheduler.scheduleAtFixedRate(task, delay, delay, TimeUnit.MILLISECONDS);\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/cache/AuthDefaultCache.java",
    "content": "package me.zhyd.oauth.cache;\n\nimport lombok.Getter;\nimport lombok.Setter;\n\nimport java.io.Serializable;\nimport java.util.Iterator;\nimport java.util.Map;\nimport java.util.concurrent.ConcurrentHashMap;\nimport java.util.concurrent.locks.Lock;\nimport java.util.concurrent.locks.ReentrantReadWriteLock;\n\n/**\n * 默认的缓存实现\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.9.3\n */\npublic class AuthDefaultCache implements AuthCache {\n\n    /**\n     * state cache\n     */\n    private static Map<String, CacheState> stateCache = new ConcurrentHashMap<>();\n    private final ReentrantReadWriteLock cacheLock = new ReentrantReadWriteLock(true);\n    private final Lock writeLock = cacheLock.writeLock();\n    private final Lock readLock = cacheLock.readLock();\n\n    public AuthDefaultCache() {\n        if (AuthCacheConfig.schedulePrune) {\n            this.schedulePrune(AuthCacheConfig.timeout);\n        }\n    }\n\n    /**\n     * 设置缓存\n     *\n     * @param key   缓存KEY\n     * @param value 缓存内容\n     */\n    @Override\n    public void set(String key, String value) {\n        set(key, value, AuthCacheConfig.timeout);\n    }\n\n    /**\n     * 设置缓存\n     *\n     * @param key     缓存KEY\n     * @param value   缓存内容\n     * @param timeout 指定缓存过期时间（毫秒）\n     */\n    @Override\n    public void set(String key, String value, long timeout) {\n        writeLock.lock();\n        try {\n            stateCache.put(key, new CacheState(value, timeout));\n        } finally {\n            writeLock.unlock();\n        }\n    }\n\n    /**\n     * 获取缓存\n     *\n     * @param key 缓存KEY\n     * @return 缓存内容\n     */\n    @Override\n    public String get(String key) {\n        readLock.lock();\n        try {\n            CacheState cacheState = stateCache.get(key);\n            if (null == cacheState || cacheState.isExpired()) {\n                return null;\n            }\n            return cacheState.getState();\n        } finally {\n            readLock.unlock();\n        }\n    }\n\n    /**\n     * 是否存在key，如果对应key的value值已过期，也返回false\n     *\n     * @param key 缓存KEY\n     * @return true：存在key，并且value没过期；false：key不存在或者已过期\n     */\n    @Override\n    public boolean containsKey(String key) {\n        readLock.lock();\n        try {\n            CacheState cacheState = stateCache.get(key);\n            return null != cacheState && !cacheState.isExpired();\n        } finally {\n            readLock.unlock();\n        }\n    }\n\n    /**\n     * 清理过期的缓存\n     */\n    @Override\n    public void pruneCache() {\n        Iterator<CacheState> values = stateCache.values().iterator();\n        CacheState cacheState;\n        while (values.hasNext()) {\n            cacheState = values.next();\n            if (cacheState.isExpired()) {\n                values.remove();\n            }\n        }\n    }\n\n    /**\n     * 定时清理\n     *\n     * @param delay 间隔时长，单位毫秒\n     */\n    public void schedulePrune(long delay) {\n        AuthCacheScheduler.INSTANCE.schedule(this::pruneCache, delay);\n    }\n\n    @Getter\n    @Setter\n    private class CacheState implements Serializable {\n        private String state;\n        private long expire;\n\n        CacheState(String state, long expire) {\n            this.state = state;\n            // 实际过期时间等于当前时间加上有效期\n            this.expire = System.currentTimeMillis() + expire;\n        }\n\n        boolean isExpired() {\n            return System.currentTimeMillis() > this.expire;\n        }\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/cache/AuthDefaultStateCache.java",
    "content": "package me.zhyd.oauth.cache;\n\n/**\n * 默认的state缓存实现\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.10.0\n */\npublic enum AuthDefaultStateCache implements AuthStateCache {\n\n    /**\n     * 当前实例\n     */\n    INSTANCE;\n\n    private AuthCache authCache;\n\n    AuthDefaultStateCache() {\n        authCache = new AuthDefaultCache();\n    }\n\n    /**\n     * 存入缓存\n     *\n     * @param key   缓存key\n     * @param value 缓存内容\n     */\n    @Override\n    public void cache(String key, String value) {\n        authCache.set(key, value);\n    }\n\n    /**\n     * 存入缓存\n     *\n     * @param key     缓存key\n     * @param value   缓存内容\n     * @param timeout 指定缓存过期时间（毫秒）\n     */\n    @Override\n    public void cache(String key, String value, long timeout) {\n        authCache.set(key, value, timeout);\n    }\n\n    /**\n     * 获取缓存内容\n     *\n     * @param key 缓存key\n     * @return 缓存内容\n     */\n    @Override\n    public String get(String key) {\n        return authCache.get(key);\n    }\n\n    /**\n     * 是否存在key，如果对应key的value值已过期，也返回false\n     *\n     * @param key 缓存key\n     * @return true：存在key，并且value没过期；false：key不存在或者已过期\n     */\n    @Override\n    public boolean containsKey(String key) {\n        return authCache.containsKey(key);\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/cache/AuthStateCache.java",
    "content": "package me.zhyd.oauth.cache;\n\n/**\n * <p>\n * State缓存接口，方便用户扩展\n * </p>\n *\n * @author yangkai.shen\n * @since 1.10.0\n */\npublic interface AuthStateCache {\n    /**\n     * 存入缓存\n     *\n     * @param key   缓存key\n     * @param value 缓存内容\n     */\n    void cache(String key, String value);\n\n    /**\n     * 存入缓存\n     *\n     * @param key     缓存key\n     * @param value   缓存内容\n     * @param timeout 指定缓存过期时间（毫秒）\n     */\n    void cache(String key, String value, long timeout);\n\n    /**\n     * 获取缓存内容\n     *\n     * @param key 缓存key\n     * @return 缓存内容\n     */\n    String get(String key);\n\n    /**\n     * 是否存在key，如果对应key的value值已过期，也返回false\n     *\n     * @param key 缓存key\n     * @return true：存在key，并且value没过期；false：key不存在或者已过期\n     */\n    boolean containsKey(String key);\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/cache/package-info.java",
    "content": "/**\n * JustAuth 缓存实现， 提供基础的基于ConcurrentHashMap + ScheduledExecutorService 实现的定时缓存。\n * 同时对外暴露{@code AuthStateCache}接口，可进行对缓存实现的自定义。\n */\npackage me.zhyd.oauth.cache;\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/config/AuthConfig.java",
    "content": "package me.zhyd.oauth.config;\n\nimport com.xkcoding.http.config.HttpConfig;\nimport lombok.*;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.utils.StringUtils;\n\nimport java.util.List;\n\n/**\n * JustAuth配置类\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.8\n */\n@Getter\n@Setter\n@Builder\n@NoArgsConstructor\n@AllArgsConstructor\npublic class AuthConfig {\n\n    /**\n     * 客户端id：对应各平台的appKey\n     */\n    private String clientId;\n\n    /**\n     * 客户端Secret：对应各平台的appSecret\n     */\n    private String clientSecret;\n\n    /**\n     * 登录成功后的回调地址\n     */\n    private String redirectUri;\n\n    /**\n     * 支付宝公钥：当选择支付宝登录时，该值可用\n     * 对应“RSA2(SHA256)密钥”中的“支付宝公钥”\n     *\n     * @deprecated 请使用AuthAlipayRequest的构造方法设置\"alipayPublicKey\"\n     */\n    @Deprecated\n    private String alipayPublicKey;\n\n    /**\n     * 是否需要申请unionid，目前只针对qq登录\n     * 注：qq授权登录时，获取unionid需要单独发送邮件申请权限。如果个人开发者账号中申请了该权限，可以将该值置为true，在获取openId时就会同步获取unionId\n     * 参考链接：http://wiki.connect.qq.com/unionid%E4%BB%8B%E7%BB%8D\n     * <p>\n     * 1.7.1版本新增参数\n     */\n    private boolean unionId;\n\n    /**\n     * Stack Overflow Key\n     * <p>\n     *\n     * @since 1.9.0\n     */\n    private String stackOverflowKey;\n\n    /**\n     * 企业微信，授权方的网页应用ID\n     *\n     * @since 1.10.0\n     */\n    private String agentId;\n\n    /**\n     * 企业微信第三方授权用户类型，member|admin\n     *\n     * @since 1.10.0\n     */\n    private String usertype;\n\n    /**\n     * 域名前缀。\n     * <p>\n     * 使用 Coding 登录和 Okta 登录时，需要传该值。\n     * <p>\n     * Coding 登录：团队域名前缀，比如以“ https://justauth.coding.net ”为例，{@code domainPrefix} = justauth\n     * <p>\n     * Okta 登录：Okta 账号域名前缀，比如以“ https://justauth.okta.com ”为例，{@code domainPrefix} = justauth\n     *\n     * @since 1.16.0\n     */\n    private String domainPrefix;\n\n    /**\n     * 针对国外服务可以单独设置代理\n     * HttpConfig config = new HttpConfig();\n     * config.setProxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(\"127.0.0.1\", 10080)));\n     * config.setTimeout(15000);\n     *\n     * @since 1.15.5\n     */\n    private HttpConfig httpConfig;\n\n    /**\n     * 忽略校验 {@code state} 参数，默认不开启。当 {@code ignoreCheckState} 为 {@code true} 时，\n     * {@link me.zhyd.oauth.request.AuthDefaultRequest#login(AuthCallback)} 将不会校验 {@code state} 的合法性。\n     * <p>\n     * 使用场景：当且仅当使用自实现 {@code state} 校验逻辑时开启\n     * <p>\n     * 以下场景使用方案仅作参考：\n     * 1. 授权、登录为同端，并且全部使用 JustAuth 实现时，该值建议设为 {@code false};\n     * 2. 授权和登录为不同端实现时，比如前端页面拼装 {@code authorizeUrl}，并且前端自行对{@code state}进行校验，\n     * 后端只负责使用{@code code}获取用户信息时，该值建议设为 {@code true};\n     *\n     * <strong>如非特殊需要，不建议开启这个配置</strong>\n     * <p>\n     * 该方案主要为了解决以下类似场景的问题：\n     *\n     * @see <a href=\"https://github.com/justauth/JustAuth/issues/83\">https://github.com/justauth/JustAuth/issues/83</a>\n     * @since 1.15.6\n     */\n    private boolean ignoreCheckState;\n\n    /**\n     * 支持自定义授权平台的 scope 内容\n     *\n     * @since 1.15.7\n     */\n    private List<String> scopes;\n\n    /**\n     * 设备ID, 设备唯一标识ID\n     *\n     * @since 1.15.8\n     */\n    private String deviceId;\n\n    /**\n     * 喜马拉雅：客户端操作系统类型，1-iOS系统，2-Android系统，3-Web\n     *\n     * @since 1.15.9\n     */\n    private Integer clientOsType;\n\n    /**\n     * 喜马拉雅：客户端包名，如果 {@link AuthConfig#clientOsType} 为1或2时必填。对Android客户端是包名，对IOS客户端是Bundle ID\n     *\n     * @since 1.15.9\n     */\n    private String packId;\n\n    /**\n     * 是否开启 PKCE 模式，该配置仅用于支持 PKCE 模式的平台，针对无服务应用，不推荐使用隐式授权，推荐使用 PKCE 模式\n     *\n     * @since 1.15.9\n     */\n    private boolean pkce;\n\n    /**\n     * Okta 授权服务器的 ID， 默认为 default。如果要使用自定义授权服务，此处传实际的授权服务器 ID（一个随机串）\n     * <p>\n     * 创建自定义授权服务器，请参考：\n     * <p>\n     * ① https://developer.okta.com/docs/concepts/auth-servers\n     * <p>\n     * ② https://developer.okta.com/docs/guides/customize-authz-server\n     *\n     * @since 1.16.0\n     */\n    private String authServerId;\n    /**\n     * 忽略校验 {@code redirectUri} 参数，默认不开启。当 {@code ignoreCheckRedirectUri} 为 {@code true} 时，\n     * {@link me.zhyd.oauth.utils.AuthChecker#checkConfig(AuthConfig, AuthSource)} 将不会校验 {@code redirectUri} 的合法性。\n     *\n     * @since 1.16.1\n     */\n    private boolean ignoreCheckRedirectUri;\n\n    /**\n     * 适配 builder 模式 set 值的情况\n     *\n     * @return authServerId\n     */\n    public String getAuthServerId() {\n        return StringUtils.isEmpty(authServerId) ? \"default\" : authServerId;\n    }\n\n    /**\n     * Microsoft Entra ID（原微软 AAD）中的租户 ID\n     */\n    private String tenantId;\n\n    /**\n     * 苹果开发者账号中的密钥标识符\n     * @see <a href=\"https://developer.apple.com/help/account/configure-app-capabilities/create-a-sign-in-with-apple-private-key/\">create-a-sign-in-with-apple-private-key</a>\n     */\n    private String kid;\n\n    /**\n     * 苹果开发者账号中的团队ID\n     * @see <a href=\"https://developer.apple.com/help/glossary/team-id/\">team id</a>\n     */\n    private String teamId;\n\n    /**\n     * 新版企业微信 Web 登录时的参数，\n     *\n     * 登录类型。ServiceApp：服务商登录；CorpApp：企业自建/代开发应用登录。\n     * @see <a href=\"https://developer.work.weixin.qq.com/document/path/98152\">https://developer.work.weixin.qq.com/document/path/98152</a>\n     * @since 1.16.7\n     */\n    private String loginType = \"CorpApp\";\n\n    /**\n     * 企业微信平台的语言编码\n     *\n     * @since 1.16.7\n     */\n    private String lang = \"zh\";\n\n    /**\n     * 钉钉平台参数：控制输出特定类型的组织列表，org_type=management 表示只输出有管理权限的组织。\n     *\n     * scope包含corpid时该参数存在意义。\n     *\n     * @see <a href=\"https://open.dingtalk.com/document/orgapp/obtain-identity-credentials#title-4up-u8w-5ug\">https://open.dingtalk.com/document/orgapp/obtain-identity-credentials#title-4up-u8w-5ug</a>\n     * @since 1.16.7\n     */\n    private String dingTalkOrgType;\n\n    /**\n     * 钉钉平台参数：用于指定用户需要选择的组织。\n     *\n     * scope包含corpid时该参数存在意义。传入的corpId需要是当前用户所在的组织。\n     *\n     * @see <a href=\"https://open.dingtalk.com/document/orgapp/obtain-identity-credentials#title-4up-u8w-5ug\">https://open.dingtalk.com/document/orgapp/obtain-identity-credentials#title-4up-u8w-5ug</a>\n     * @since 1.16.7\n     */\n    private String dingTalkCorpId;\n\n    /**\n     * 钉钉平台参数：true表示专属帐号登录，展示组织代码输入页。\n     *\n     * @see <a href=\"https://open.dingtalk.com/document/orgapp/obtain-identity-credentials#title-4up-u8w-5ug\">https://open.dingtalk.com/document/orgapp/obtain-identity-credentials#title-4up-u8w-5ug</a>\n     * @since 1.16.7\n     */\n    private boolean dingTalkExclusiveLogin;\n\n    /**\n     * 钉钉平台参数：开启了专属帐号功能的组织corpId。\n     *\n     * scope包含corpid时该参数存在意义。传入的corpId需要是当前用户所在的组织。\n     *\n     * @see <a href=\"https://open.dingtalk.com/document/orgapp/obtain-identity-credentials#title-4up-u8w-5ug\">https://open.dingtalk.com/document/orgapp/obtain-identity-credentials#title-4up-u8w-5ug</a>\n     * @since 1.16.7\n     */\n    private String dingTalkExclusiveCorpId;\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/config/AuthDefaultSource.java",
    "content": "package me.zhyd.oauth.config;\n\nimport me.zhyd.oauth.enums.AuthResponseStatus;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.request.*;\n\n/**\n * JustAuth内置的各api需要的url， 用枚举类分平台类型管理\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.0\n */\npublic enum AuthDefaultSource implements AuthSource {\n    /**\n     * Github\n     */\n    GITHUB {\n        @Override\n        public String authorize() {\n            return \"https://github.com/login/oauth/authorize\";\n        }\n\n        @Override\n        public String accessToken() {\n            return \"https://github.com/login/oauth/access_token\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"https://api.github.com/user\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthGithubRequest.class;\n        }\n    },\n    /**\n     * 新浪微博\n     */\n    WEIBO {\n        @Override\n        public String authorize() {\n            return \"https://api.weibo.com/oauth2/authorize\";\n        }\n\n        @Override\n        public String accessToken() {\n            return \"https://api.weibo.com/oauth2/access_token\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"https://api.weibo.com/2/users/show.json\";\n        }\n\n        @Override\n        public String revoke() {\n            return \"https://api.weibo.com/oauth2/revokeoauth2\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthWeiboRequest.class;\n        }\n    },\n    /**\n     * gitee\n     */\n    GITEE {\n        @Override\n        public String authorize() {\n            return \"https://gitee.com/oauth/authorize\";\n        }\n\n        @Override\n        public String accessToken() {\n            return \"https://gitee.com/oauth/token\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"https://gitee.com/api/v5/user\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthGiteeRequest.class;\n        }\n    },\n    /**\n     * 钉钉扫码登录\n     */\n    DINGTALK {\n        @Override\n        public String authorize() {\n            return \"https://oapi.dingtalk.com/connect/qrconnect\";\n        }\n\n        @Override\n        public String accessToken() {\n            throw new AuthException(AuthResponseStatus.UNSUPPORTED);\n        }\n\n        @Override\n        public String userInfo() {\n            return \"https://oapi.dingtalk.com/sns/getuserinfo_bycode\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthDingTalkRequest.class;\n        }\n    },\n    /**\n     * 新版钉钉扫码登录\n     */\n    DINGTALK_V2 {\n        @Override\n        public String authorize() {\n            return \"https://login.dingtalk.com/oauth2/challenge.htm\";\n        }\n\n        @Override\n        public String accessToken() {\n            return \"https://api.dingtalk.com/v1.0/oauth2/userAccessToken\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"https://api.dingtalk.com/v1.0/contact/users/me\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthDingTalkV2Request.class;\n        }\n    },\n    /**\n     * 钉钉账号登录\n     */\n    DINGTALK_ACCOUNT {\n        @Override\n        public String authorize() {\n            return \"https://oapi.dingtalk.com/connect/oauth2/sns_authorize\";\n        }\n\n        @Override\n        public String accessToken() {\n            return DINGTALK.accessToken();\n        }\n\n        @Override\n        public String userInfo() {\n            return DINGTALK.userInfo();\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthDingTalkAccountRequest.class;\n        }\n    },\n    /**\n     * 百度\n     */\n    BAIDU {\n        @Override\n        public String authorize() {\n            return \"https://openapi.baidu.com/oauth/2.0/authorize\";\n        }\n\n        @Override\n        public String accessToken() {\n            return \"https://openapi.baidu.com/oauth/2.0/token\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"https://openapi.baidu.com/rest/2.0/passport/users/getInfo\";\n        }\n\n        @Override\n        public String revoke() {\n            return \"https://openapi.baidu.com/rest/2.0/passport/auth/revokeAuthorization\";\n        }\n\n        @Override\n        public String refresh() {\n            return \"https://openapi.baidu.com/oauth/2.0/token\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthBaiduRequest.class;\n        }\n    },\n    /**\n     * csdn\n     */\n    CSDN {\n        @Override\n        public String authorize() {\n            return \"https://api.csdn.net/oauth2/authorize\";\n        }\n\n        @Override\n        public String accessToken() {\n            return \"https://api.csdn.net/oauth2/access_token\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"https://api.csdn.net/user/getinfo\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthCsdnRequest.class;\n        }\n    },\n    /**\n     * Coding，\n     * <p>\n     * 参考 https://help.coding.net/docs/project/open/oauth.html#%E7%94%A8%E6%88%B7%E6%8E%88%E6%9D%83 中的说明，\n     * 新版的 coding API 地址需要传入用户团队名，这儿使用动态参数，方便在 request 中使用\n     */\n    CODING {\n        @Override\n        public String authorize() {\n            return \"https://%s.coding.net/oauth_authorize.html\";\n        }\n\n        @Override\n        public String accessToken() {\n            return \"https://%s.coding.net/api/oauth/access_token\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"https://%s.coding.net/api/account/current_user\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthCodingRequest.class;\n        }\n    },\n    /**\n     * oschina 开源中国\n     */\n    OSCHINA {\n        @Override\n        public String authorize() {\n            return \"https://www.oschina.net/action/oauth2/authorize\";\n        }\n\n        @Override\n        public String accessToken() {\n            return \"https://www.oschina.net/action/openapi/token\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"https://www.oschina.net/action/openapi/user\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthOschinaRequest.class;\n        }\n    },\n    /**\n     * 支付宝\n     */\n    ALIPAY {\n        @Override\n        public String authorize() {\n            return \"https://openauth.alipay.com/oauth2/publicAppAuthorize.htm\";\n        }\n\n        @Override\n        public String accessToken() {\n            return \"https://openapi.alipay.com/gateway.do\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"https://openapi.alipay.com/gateway.do\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthAlipayRequest.class;\n        }\n    },\n    /**\n     * QQ\n     */\n    QQ {\n        @Override\n        public String authorize() {\n            return \"https://graph.qq.com/oauth2.0/authorize\";\n        }\n\n        @Override\n        public String accessToken() {\n            return \"https://graph.qq.com/oauth2.0/token\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"https://graph.qq.com/user/get_user_info\";\n        }\n\n        @Override\n        public String refresh() {\n            return \"https://graph.qq.com/oauth2.0/token\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthQqRequest.class;\n        }\n    },\n    /**\n     * 微信开放平台\n     */\n    WECHAT_OPEN {\n        @Override\n        public String authorize() {\n            return \"https://open.weixin.qq.com/connect/qrconnect\";\n        }\n\n        @Override\n        public String accessToken() {\n            return \"https://api.weixin.qq.com/sns/oauth2/access_token\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"https://api.weixin.qq.com/sns/userinfo\";\n        }\n\n        @Override\n        public String refresh() {\n            return \"https://api.weixin.qq.com/sns/oauth2/refresh_token\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthWeChatOpenRequest.class;\n        }\n    },\n    /**\n     * 微信公众平台\n     */\n    WECHAT_MP {\n        @Override\n        public String authorize() {\n            return \"https://open.weixin.qq.com/connect/oauth2/authorize\";\n        }\n\n        @Override\n        public String accessToken() {\n            return \"https://api.weixin.qq.com/sns/oauth2/access_token\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"https://api.weixin.qq.com/sns/userinfo\";\n        }\n\n        @Override\n        public String refresh() {\n            return \"https://api.weixin.qq.com/sns/oauth2/refresh_token\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthWeChatMpRequest.class;\n        }\n    },\n    /**\n     * 淘宝\n     */\n    TAOBAO {\n        @Override\n        public String authorize() {\n            return \"https://oauth.taobao.com/authorize\";\n        }\n\n        @Override\n        public String accessToken() {\n            return \"https://oauth.taobao.com/token\";\n        }\n\n        @Override\n        public String userInfo() {\n            throw new AuthException(AuthResponseStatus.UNSUPPORTED);\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthTaobaoRequest.class;\n        }\n    },\n    /**\n     * Google\n     * 端点地址：https://accounts.google.com/.well-known/openid-configuration\n     */\n    GOOGLE {\n        @Override\n        public String authorize() {\n            return \"https://accounts.google.com/o/oauth2/v2/auth\";\n        }\n\n        @Override\n        public String accessToken() {\n            return \"https://oauth2.googleapis.com/token\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"https://openidconnect.googleapis.com/v1/userinfo\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthGoogleRequest.class;\n        }\n    },\n    /**\n     * Facebook\n     */\n    FACEBOOK {\n        @Override\n        public String authorize() {\n            return \"https://www.facebook.com/v18.0/dialog/oauth\";\n        }\n\n        @Override\n        public String accessToken() {\n            return \"https://graph.facebook.com/v18.0/oauth/access_token\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"https://graph.facebook.com/v18.0/me\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthFacebookRequest.class;\n        }\n    },\n    /**\n     * 抖音\n     */\n    DOUYIN {\n        @Override\n        public String authorize() {\n            return \"https://open.douyin.com/platform/oauth/connect\";\n        }\n\n        @Override\n        public String accessToken() {\n            return \"https://open.douyin.com/oauth/access_token/\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"https://open.douyin.com/oauth/userinfo/\";\n        }\n\n        @Override\n        public String refresh() {\n            return \"https://open.douyin.com/oauth/refresh_token/\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthDouyinRequest.class;\n        }\n    },\n    /**\n     * 领英\n     */\n    LINKEDIN {\n        @Override\n        public String authorize() {\n            return \"https://www.linkedin.com/oauth/v2/authorization\";\n        }\n\n        @Override\n        public String accessToken() {\n            return \"https://www.linkedin.com/oauth/v2/accessToken\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"https://api.linkedin.com/v2/me\";\n        }\n\n        @Override\n        public String refresh() {\n            return \"https://www.linkedin.com/oauth/v2/accessToken\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthLinkedinRequest.class;\n        }\n    },\n    /**\n     * 微软\n     */\n    MICROSOFT {\n        @Override\n        public String authorize() {\n            return \"https://login.microsoftonline.com/%s/oauth2/v2.0/authorize\";\n        }\n\n        @Override\n        public String accessToken() {\n            return \"https://login.microsoftonline.com/%s/oauth2/v2.0/token\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"https://graph.microsoft.com/v1.0/me\";\n        }\n\n        @Override\n        public String refresh() {\n            return \"https://login.microsoftonline.com/%s/oauth2/v2.0/token\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthMicrosoftRequest.class;\n        }\n    },\n    /**\n     * 微软中国(世纪互联)\n     */\n    MICROSOFT_CN {\n        @Override\n        public String authorize() {\n            return \"https://login.partner.microsoftonline.cn/%s/oauth2/v2.0/authorize\";\n        }\n\n        @Override\n        public String accessToken() {\n            return \"https://login.partner.microsoftonline.cn/%s/oauth2/v2.0/token\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"https://microsoftgraph.chinacloudapi.cn/v1.0/me\";\n        }\n\n        @Override\n        public String refresh() {\n            return \"https://login.partner.microsoftonline.cn/%s/oauth2/v2.0/token\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() { return AuthMicrosoftCnRequest.class; }\n    },\n    /**\n     * 小米\n     */\n    MI {\n        @Override\n        public String authorize() {\n            return \"https://account.xiaomi.com/oauth2/authorize\";\n        }\n\n        @Override\n        public String accessToken() {\n            return \"https://account.xiaomi.com/oauth2/token\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"https://open.account.xiaomi.com/user/profile\";\n        }\n\n        @Override\n        public String refresh() {\n            return \"https://account.xiaomi.com/oauth2/token\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthMiRequest.class;\n        }\n    },\n    /**\n     * 今日头条\n     */\n    TOUTIAO {\n        @Override\n        public String authorize() {\n            return \"https://open.snssdk.com/auth/authorize\";\n        }\n\n        @Override\n        public String accessToken() {\n            return \"https://open.snssdk.com/auth/token\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"https://open.snssdk.com/data/user_profile\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthToutiaoRequest.class;\n        }\n    },\n    /**\n     * Teambition\n     */\n    TEAMBITION {\n        @Override\n        public String authorize() {\n            return \"https://account.teambition.com/oauth2/authorize\";\n        }\n\n        @Override\n        public String accessToken() {\n            return \"https://account.teambition.com/oauth2/access_token\";\n        }\n\n        @Override\n        public String refresh() {\n            return \"https://account.teambition.com/oauth2/refresh_token\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"https://api.teambition.com/users/me\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthTeambitionRequest.class;\n        }\n    },\n\n    /**\n     * 人人网\n     */\n    RENREN {\n        @Override\n        public String authorize() {\n            return \"https://graph.renren.com/oauth/authorize\";\n        }\n\n        @Override\n        public String accessToken() {\n            return \"https://graph.renren.com/oauth/token\";\n        }\n\n        @Override\n        public String refresh() {\n            return \"https://graph.renren.com/oauth/token\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"https://api.renren.com/v2/user/get\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthRenrenRequest.class;\n        }\n    },\n\n    /**\n     * Pinterest\n     */\n    PINTEREST {\n        @Override\n        public String authorize() {\n            return \"https://api.pinterest.com/oauth\";\n        }\n\n        @Override\n        public String accessToken() {\n            return \"https://api.pinterest.com/v1/oauth/token\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"https://api.pinterest.com/v1/me\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthPinterestRequest.class;\n        }\n    },\n\n    /**\n     * Stack Overflow\n     */\n    STACK_OVERFLOW {\n        @Override\n        public String authorize() {\n            return \"https://stackoverflow.com/oauth\";\n        }\n\n        @Override\n        public String accessToken() {\n            return \"https://stackoverflow.com/oauth/access_token/json\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"https://api.stackexchange.com/2.2/me\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthStackOverflowRequest.class;\n        }\n    },\n\n    /**\n     * 华为\n     *\n     * 当前方式未来可能被废弃，建议使用 {@link this#HUAWEI_V3}\n     *\n     * @since 1.10.0\n     */\n    @Deprecated\n    HUAWEI {\n        @Override\n        public String authorize() {\n            return \"https://oauth-login.cloud.huawei.com/oauth2/v2/authorize\";\n        }\n\n        @Override\n        public String accessToken() {\n            return \"https://oauth-login.cloud.huawei.com/oauth2/v2/token\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"https://api.vmall.com/rest.php\";\n        }\n\n        @Override\n        public String refresh() {\n            return \"https://oauth-login.cloud.huawei.com/oauth2/v2/token\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthHuaweiRequest.class;\n        }\n    },\n\n    /**\n     * 华为最新版本的 API\n     *\n     * @since 1.16.7\n     */\n    HUAWEI_V3 {\n        @Override\n        public String authorize() {\n            return \"https://oauth-login.cloud.huawei.com/oauth2/v3/authorize\";\n        }\n\n        @Override\n        public String accessToken() {\n            return \"https://oauth-login.cloud.huawei.com/oauth2/v3/token\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"https://account.cloud.huawei.com/rest.php\";\n        }\n\n        @Override\n        public String refresh() {\n            return \"https://oauth-login.cloud.huawei.com/oauth2/v3/token\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthHuaweiV3Request.class;\n        }\n    },\n\n    /**\n     * 企业微信二维码登录\n     *\n     * @since 1.10.0\n     */\n    WECHAT_ENTERPRISE {\n        @Override\n        public String authorize() {\n            return \"https://open.work.weixin.qq.com/wwopen/sso/qrConnect\";\n        }\n\n        @Override\n        public String accessToken() {\n            return \"https://qyapi.weixin.qq.com/cgi-bin/gettoken\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthWeChatEnterpriseQrcodeRequest.class;\n        }\n    },\n    /**\n     * 新版企业微信 Web 登录（扫码），参考 <a href=\"https://developer.work.weixin.qq.com/document/path/98152\">https://developer.work.weixin.qq.com/document/path/98152</a>\n     *\n     * @since 1.16.7\n     */\n    WECHAT_ENTERPRISE_V2 {\n        @Override\n        public String authorize() {\n            return \"https://login.work.weixin.qq.com/wwlogin/sso/login\";\n        }\n\n        @Override\n        public String accessToken() {\n            return \"https://qyapi.weixin.qq.com/cgi-bin/gettoken\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"https://qyapi.weixin.qq.com/cgi-bin/auth/getuserinfo\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthWeChatEnterpriseQrcodeV2Request.class;\n        }\n    },\n    /**\n     * 企业微信二维码第三方登录\n     */\n    WECHAT_ENTERPRISE_QRCODE_THIRD {\n        /**\n         * 授权的api\n         *\n         * @return url\n         */\n        @Override\n        public String authorize() {\n            return \"https://open.work.weixin.qq.com/wwopen/sso/3rd_qrConnect\";\n        }\n\n        /**\n         * 获取accessToken的api\n         *\n         * @return url\n         */\n        @Override\n        public String accessToken() {\n            return \"https://qyapi.weixin.qq.com/cgi-bin/service/get_provider_token\";\n        }\n\n        /**\n         * 获取用户信息的api\n         *\n         * @return url\n         */\n        @Override\n        public String userInfo() {\n            return \"https://qyapi.weixin.qq.com/cgi-bin/service/get_login_info\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthWeChatEnterpriseThirdQrcodeRequest.class;\n        }\n    },\n    /**\n     * 企业微信网页登录\n     */\n    WECHAT_ENTERPRISE_WEB {\n        @Override\n        public String authorize() {\n            return \"https://open.weixin.qq.com/connect/oauth2/authorize\";\n        }\n\n        @Override\n        public String accessToken() {\n            return \"https://qyapi.weixin.qq.com/cgi-bin/gettoken\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthWeChatEnterpriseWebRequest.class;\n        }\n    },\n\n    /**\n     * 酷家乐\n     *\n     * @since 1.11.0\n     */\n    KUJIALE {\n        @Override\n        public String authorize() {\n            return \"https://oauth.kujiale.com/oauth2/show\";\n        }\n\n        @Override\n        public String accessToken() {\n            return \"https://oauth.kujiale.com/oauth2/auth/token\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"https://oauth.kujiale.com/oauth2/openapi/user\";\n        }\n\n        @Override\n        public String refresh() {\n            return \"https://oauth.kujiale.com/oauth2/auth/token/refresh\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthKujialeRequest.class;\n        }\n    },\n\n    /**\n     * Gitlab\n     *\n     * @since 1.11.0\n     */\n    GITLAB {\n        @Override\n        public String authorize() {\n            return \"https://gitlab.com/oauth/authorize\";\n        }\n\n        @Override\n        public String accessToken() {\n            return \"https://gitlab.com/oauth/token\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"https://gitlab.com/api/v4/user\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthGitlabRequest.class;\n        }\n    },\n\n    /**\n     * 美团\n     *\n     * @since 1.12.0\n     */\n    MEITUAN {\n        @Override\n        public String authorize() {\n            return \"https://openapi.waimai.meituan.com/oauth/authorize\";\n        }\n\n        @Override\n        public String accessToken() {\n            return \"https://openapi.waimai.meituan.com/oauth/access_token\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"https://openapi.waimai.meituan.com/oauth/userinfo\";\n        }\n\n        @Override\n        public String refresh() {\n            return \"https://openapi.waimai.meituan.com/oauth/refresh_token\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthMeituanRequest.class;\n        }\n    },\n\n    /**\n     * 饿了么\n     * <p>\n     * 注：集成的是正式环境，非沙箱环境\n     *\n     * @since 1.12.0\n     */\n    ELEME {\n        @Override\n        public String authorize() {\n            return \"https://open-api.shop.ele.me/authorize\";\n        }\n\n        @Override\n        public String accessToken() {\n            return \"https://open-api.shop.ele.me/token\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"https://open-api.shop.ele.me/api/v1/\";\n        }\n\n        @Override\n        public String refresh() {\n            return \"https://open-api.shop.ele.me/token\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthElemeRequest.class;\n        }\n    },\n\n    /**\n     * Twitter\n     *\n     * @since 1.13.0\n     */\n    TWITTER {\n        @Override\n        public String authorize() {\n            return \"https://api.twitter.com/oauth/authenticate\";\n        }\n\n        @Override\n        public String accessToken() {\n            return \"https://api.twitter.com/oauth/access_token\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"https://api.twitter.com/1.1/account/verify_credentials.json\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthTwitterRequest.class;\n        }\n    },\n\n    /**\n     * 飞书平台，企业自建应用授权登录，原逻辑由 beacon 集成于 1.14.0 版，但最新的飞书 api 已修改，并且飞书平台一直为 {@code Deprecated} 状态\n     * <p>\n     * 所以，最终修改该平台的实际发布版本为 1.15.9\n     *\n     * @since 1.15.9\n     */\n    FEISHU {\n        @Override\n        public String authorize() {\n            return \"https://open.feishu.cn/open-apis/authen/v1/index\";\n        }\n\n        @Override\n        public String accessToken() {\n            return \"https://open.feishu.cn/open-apis/authen/v1/access_token\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"https://open.feishu.cn/open-apis/authen/v1/user_info\";\n        }\n\n        @Override\n        public String refresh() {\n            return \"https://open.feishu.cn/open-apis/authen/v1/refresh_access_token\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthFeishuRequest.class;\n        }\n    },\n    /**\n     * 京东\n     *\n     * @since 1.15.0\n     */\n    JD {\n        @Override\n        public String authorize() {\n            return \"https://open-oauth.jd.com/oauth2/to_login\";\n        }\n\n        @Override\n        public String accessToken() {\n            return \"https://open-oauth.jd.com/oauth2/access_token\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"https://api.jd.com/routerjson\";\n        }\n\n        @Override\n        public String refresh() {\n            return \"https://open-oauth.jd.com/oauth2/refresh_token\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthJdRequest.class;\n        }\n    },\n\n    /**\n     * 阿里云\n     */\n    ALIYUN {\n        @Override\n        public String authorize() {\n            return \"https://signin.aliyun.com/oauth2/v1/auth\";\n        }\n\n        @Override\n        public String accessToken() {\n            return \"https://oauth.aliyun.com/v1/token\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"https://oauth.aliyun.com/v1/userinfo\";\n        }\n\n        @Override\n        public String refresh() {\n            return \"https://oauth.aliyun.com/v1/token\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthAliyunRequest.class;\n        }\n    },\n\n    /**\n     * 喜马拉雅\n     */\n    XMLY {\n        @Override\n        public String authorize() {\n            return \"https://api.ximalaya.com/oauth2/js/authorize\";\n        }\n\n        @Override\n        public String accessToken() {\n            return \"https://api.ximalaya.com/oauth2/v2/access_token\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"https://api.ximalaya.com/profile/user_info\";\n        }\n\n        @Override\n        public String refresh() {\n            return \"https://oauth.aliyun.com/v1/token\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthXmlyRequest.class;\n        }\n    },\n\n    /**\n     * Amazon\n     *\n     * @since 1.16.0\n     */\n    AMAZON {\n        @Override\n        public String authorize() {\n            return \"https://www.amazon.com/ap/oa\";\n        }\n\n        @Override\n        public String accessToken() {\n            return \"https://api.amazon.com/auth/o2/token\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"https://api.amazon.com/user/profile\";\n        }\n\n        @Override\n        public String refresh() {\n            return \"https://api.amazon.com/auth/o2/token\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthAmazonRequest.class;\n        }\n    },\n    /**\n     * Slack\n     *\n     * @since 1.16.0\n     */\n    SLACK {\n        @Override\n        public String authorize() {\n            return \"https://slack.com/oauth/v2/authorize\";\n        }\n\n        /**\n         * 该 API 获取到的是 access token\n         *\n         * https://slack.com/api/oauth.token 获取到的是 workspace token\n         *\n         * @return String\n         */\n        @Override\n        public String accessToken() {\n            return \"https://slack.com/api/oauth.v2.access\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"https://slack.com/api/users.info\";\n        }\n\n        @Override\n        public String revoke() {\n            return \"https://slack.com/api/auth.revoke\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthSlackRequest.class;\n        }\n    },\n    /**\n     * line\n     *\n     * @since 1.16.0\n     */\n    LINE {\n        @Override\n        public String authorize() {\n            return \"https://access.line.me/oauth2/v2.1/authorize\";\n        }\n\n        @Override\n        public String accessToken() {\n            return \"https://api.line.me/oauth2/v2.1/token\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"https://api.line.me/v2/profile\";\n        }\n\n        @Override\n        public String refresh() {\n            return \"https://api.line.me/oauth2/v2.1/token\";\n        }\n\n        @Override\n        public String revoke() {\n            return \"https://api.line.me/oauth2/v2.1/revoke\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthLineRequest.class;\n        }\n    },\n    /**\n     * Okta，\n     * <p>\n     * 团队/组织的域名不同，此处通过配置动态组装\n     *\n     * @since 1.16.0\n     */\n    OKTA {\n        @Override\n        public String authorize() {\n            return \"https://%s.okta.com/oauth2/%s/v1/authorize\";\n        }\n\n        @Override\n        public String accessToken() {\n            return \"https://%s.okta.com/oauth2/%s/v1/token\";\n        }\n\n        @Override\n        public String refresh() {\n            return \"https://%s.okta.com/oauth2/%s/v1/token\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"https://%s.okta.com/oauth2/%s/v1/userinfo\";\n        }\n\n        @Override\n        public String revoke() {\n            return \"https://%s.okta.com/oauth2/%s/v1/revoke\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthOktaRequest.class;\n        }\n    },\n    /**\n     * 程序员客栈\n     *\n     * @since 1.16.2\n     */\n    PROGINN {\n        @Override\n        public String authorize() {\n            return \"https://www.proginn.com/oauth2/authorize\";\n        }\n\n        @Override\n        public String accessToken() {\n            return \"https://www.proginn.com/oauth2/access_token\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"https://www.proginn.com/openapi/user/basic_info\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthProginnRequest.class;\n        }\n    },\n    /**\n     * 爱发电 <a href=\"https://afdian.net/\">爱发电</a>\n     */\n    AFDIAN {\n        @Override\n        public String authorize() {\n            return \"https://afdian.net/oauth2/authorize\";\n        }\n\n        @Override\n        public String accessToken() {\n            return \"https://afdian.net/api/oauth2/access_token\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthProginnRequest.class;\n        }\n    },\n\n    APPLE {\n        @Override\n        public String authorize() {\n            return \"https://appleid.apple.com/auth/authorize\";\n        }\n\n        /**\n         * @see <a href=\"https://developer.apple.com/documentation/sign_in_with_apple/generate_and_validate_tokens\">generate_and_validate_tokens</a>\n         */\n        @Override\n        public String accessToken() {\n            return \"https://appleid.apple.com/auth/token\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthAppleRequest.class;\n        }\n    },\n\n    FIGMA{\n        @Override\n        public String authorize() {\n            return \"https://www.figma.com/oauth\";\n        }\n\n        @Override\n        public String accessToken() {\n            return \"https://www.figma.com/api/oauth/token\";\n        }\n\n        @Override\n        public String userInfo() {\n            return \"https://api.figma.com/v1/me\";\n        }\n\n        @Override\n        public String refresh() {\n            return \"https://www.figma.com/api/oauth/refresh\";\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthFigmaRequest.class;\n        }\n    },\n    /**\n     * 微信小程序授权登录\n     * @since yudaocode\n     */\n    WECHAT_MINI_PROGRAM {\n\n        @Override\n        public String authorize() {\n            // 参见 https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/login.html 文档\n            throw new UnsupportedOperationException(\"不支持获取授权 url，请使用小程序内置函数 wx.login() 登录获取 code\");\n        }\n\n        @Override\n        public String accessToken() {\n            // 参见 https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/login/auth.code2Session.html 文档\n            // 获取 openid, unionId , session_key 等字段\n            return \"https://api.weixin.qq.com/sns/jscode2session\";\n        }\n\n        @Override\n        public String userInfo() {\n            // 参见 https://developers.weixin.qq.com/miniprogram/dev/api/open-api/user-info/wx.getUserProfile.html 文档\n            throw new UnsupportedOperationException(\"不支持获取用户信息 url，请使用小程序内置函数 wx.getUserProfile() 获取用户信息\");\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthWechatMiniProgramRequest.class;\n        }\n    },\n\n    /**\n     * QQ小程序授权登录\n     */\n    QQ_MINI_PROGRAM {\n        @Override\n        public String authorize() {\n            // 参见 https://q.qq.com/wiki/develop/miniprogram/frame/open_ability/open_userinfo.html 文档\n            throw new UnsupportedOperationException(\"不支持获取授权 url，请使用小程序内置函数 qq.login() 登录获取 code\");\n        }\n\n        @Override\n        public String accessToken() {\n            // 参见 https://q.qq.com/wiki/develop/miniprogram/server/open_port/port_login.html 文档\n            // 获取 openid, unionId , session_key 等字段\n            return \"https://api.q.qq.com/sns/jscode2session\";\n        }\n\n        @Override\n        public String userInfo() {\n            // 参见 https://q.qq.com/wiki/develop/miniprogram/API/open_port/port_userinfo.html 文档\n            throw new UnsupportedOperationException(\"不支持获取用户信息 url，请使用小程序内置函数 qq.getUserInfo() 获取用户信息\");\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return null;\n        }\n    }\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/config/AuthSource.java",
    "content": "package me.zhyd.oauth.config;\n\nimport me.zhyd.oauth.enums.AuthResponseStatus;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.request.AuthDefaultRequest;\n\n/**\n * OAuth平台的API地址的统一接口，提供以下方法：\n * 1) {@link AuthSource#authorize()}: 获取授权url. 必须实现\n * 2) {@link AuthSource#accessToken()}: 获取accessToken的url. 必须实现\n * 3) {@link AuthSource#userInfo()}: 获取用户信息的url. 必须实现\n * 4) {@link AuthSource#revoke()}: 获取取消授权的url. 非必须实现接口（部分平台不支持）\n * 5) {@link AuthSource#refresh()}: 获取刷新授权的url. 非必须实现接口（部分平台不支持）\n * <p>\n * 注：\n * ①、如需通过JustAuth扩展实现第三方授权，请参考{@link AuthDefaultSource}自行创建对应的枚举类并实现{@link AuthSource}接口\n * ②、如果不是使用的枚举类，那么在授权成功后获取用户信息时，需要单独处理source字段的赋值\n * ③、如果扩展了对应枚举类时，在{@link me.zhyd.oauth.request.AuthRequest#login(AuthCallback)}中可以通过{@code xx.toString()}获取对应的source\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @version 1.0\n * @since 1.12.0\n */\npublic interface AuthSource {\n\n    /**\n     * 授权的api\n     *\n     * @return url\n     */\n    String authorize();\n\n    /**\n     * 获取accessToken的api\n     *\n     * @return url\n     */\n    String accessToken();\n\n    /**\n     * 获取用户信息的api\n     *\n     * @return url\n     */\n    String userInfo();\n\n    /**\n     * 取消授权的api\n     *\n     * @return url\n     */\n    default String revoke() {\n        throw new AuthException(AuthResponseStatus.UNSUPPORTED);\n    }\n\n    /**\n     * 刷新授权的api\n     *\n     * @return url\n     */\n    default String refresh() {\n        throw new AuthException(AuthResponseStatus.UNSUPPORTED);\n    }\n\n    /**\n     * 获取Source的字符串名字\n     *\n     * @return name\n     */\n    default String getName() {\n        if (this instanceof Enum) {\n            return String.valueOf(this);\n        }\n        return this.getClass().getSimpleName();\n    }\n\n    /**\n     * 平台对应的 AuthRequest 实现类，必须继承自 {@link AuthDefaultRequest}\n     *\n     * @return class\n     */\n    Class<? extends AuthDefaultRequest> getTargetClass();\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/config/JustAuthLogConfig.java",
    "content": "package me.zhyd.oauth.config;\n\nimport me.zhyd.oauth.log.Log;\n\n/**\n * JustAuth 日志配置类\n *\n * @author HeJin\n */\npublic class JustAuthLogConfig {\n\n    /**\n     * 设置日志级别\n     *\n     * @param level 日志级别\n     */\n    public static void setLevel(Log.Level level) {\n        Log.Config.level = level;\n    }\n\n    /**\n     * 关闭日志\n     */\n    public static void disable() {\n        Log.Config.enable = false;\n    }\n\n    /**\n     * 开启日志\n     */\n    public static void enable() {\n        Log.Config.enable = true;\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/config/package-info.java",
    "content": "/**\n * JustAuth 核心配置相关，包括{@code AuthConfig}和{@code AuthSource}\n */\npackage me.zhyd.oauth.config;\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/enums/AuthResponseStatus.java",
    "content": "package me.zhyd.oauth.enums;\n\nimport lombok.AllArgsConstructor;\nimport lombok.Getter;\n\n/**\n * JustAuth通用的状态码对照表\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.8\n */\n@Getter\n@AllArgsConstructor\npublic enum AuthResponseStatus {\n    /**\n     * 2000：正常；\n     * other：调用异常，具体异常内容见{@code msg}\n     */\n    SUCCESS(2000, \"Success\"),\n    FAILURE(5000, \"Failure\"),\n    NOT_IMPLEMENTED(5001, \"Not Implemented\"),\n    PARAMETER_INCOMPLETE(5002, \"Parameter incomplete\"),\n    UNSUPPORTED(5003, \"Unsupported operation\"),\n    NO_AUTH_SOURCE(5004, \"AuthDefaultSource cannot be null\"),\n    UNIDENTIFIED_PLATFORM(5005, \"Unidentified platform\"),\n    ILLEGAL_REDIRECT_URI(5006, \"Illegal redirect uri\"),\n    ILLEGAL_REQUEST(5007, \"Illegal request\"),\n    ILLEGAL_CODE(5008, \"Illegal code\"),\n    ILLEGAL_STATUS(5009, \"Illegal state\"),\n    REQUIRED_REFRESH_TOKEN(5010, \"The refresh token is required; it must not be null\"),\n    ILLEGAL_TOKEN(5011, \"Invalid token\"),\n    ILLEGAL_KID(5012, \"Invalid key identifier(kid)\"),\n    ILLEGAL_TEAM_ID(5013, \"Invalid team id\"),\n    ILLEGAL_CLIENT_ID(5014, \"Invalid client id\"),\n    ILLEGAL_CLIENT_SECRET(5015, \"Invalid client secret\"),\n    ILLEGAL_WECHAT_AGENT_ID(5016, \"Illegal wechat agent id\"),\n    ;\n\n    private final int code;\n    private final String msg;\n}\n\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/enums/AuthToutiaoErrorCode.java",
    "content": "package me.zhyd.oauth.enums;\n\nimport lombok.AllArgsConstructor;\nimport lombok.Getter;\n\n/**\n * 今日头条授权登录时的异常状态码\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.8\n */\n@Getter\n@AllArgsConstructor\npublic enum AuthToutiaoErrorCode {\n    /**\n     * 0：正常；\n     * other：调用异常，具体异常内容见{@code desc}\n     */\n    EC0(0, \"接口调用成功\"),\n    EC1(1, \"API配置错误，未传入Client Key\"),\n    EC2(2, \"API配置错误，Client Key错误，请检查是否和开放平台的ClientKey一致\"),\n    EC3(3, \"没有授权信息\"),\n    EC4(4, \"响应类型错误\"),\n    EC5(5, \"授权类型错误\"),\n    EC6(6, \"client_secret错误\"),\n    EC7(7, \"authorize_code过期\"),\n    EC8(8, \"指定url的scheme不是https\"),\n    EC9(9, \"接口内部错误，请联系头条技术\"),\n    EC10(10, \"access_token过期\"),\n    EC11(11, \"缺少access_token\"),\n    EC12(12, \"参数缺失\"),\n    EC13(13, \"url错误\"),\n    EC21(21, \"域名与登记域名不匹配\"),\n    EC999(999, \"未知错误，请联系头条技术\"),\n    ;\n\n    private int code;\n    private String desc;\n\n    public static AuthToutiaoErrorCode getErrorCode(int errorCode) {\n        AuthToutiaoErrorCode[] errorCodes = AuthToutiaoErrorCode.values();\n        for (AuthToutiaoErrorCode code : errorCodes) {\n            if (code.getCode() == errorCode) {\n                return code;\n            }\n        }\n        return EC999;\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/enums/AuthUserGender.java",
    "content": "package me.zhyd.oauth.enums;\n\nimport lombok.AllArgsConstructor;\nimport lombok.Getter;\nimport me.zhyd.oauth.utils.StringUtils;\n\nimport java.util.Arrays;\n\n/**\n * 用户性别\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.8\n */\n@Getter\n@AllArgsConstructor\npublic enum AuthUserGender {\n    /**\n     * MALE/FAMALE为正常值，通过{@link AuthUserGender#getRealGender(String)}方法获取真实的性别\n     * UNKNOWN为容错值，部分平台不会返回用户性别，为了方便统一，使用UNKNOWN标记所有未知或不可测的用户性别信息\n     */\n    MALE(\"1\", \"男\"),\n    FEMALE(\"0\", \"女\"),\n    UNKNOWN(\"-1\", \"未知\");\n\n    private String code;\n    private String desc;\n\n    /**\n     * 获取用户的实际性别，常规网站\n     *\n     * @param originalGender 用户第三方标注的原始性别\n     * @return 用户性别\n     */\n    public static AuthUserGender getRealGender(String originalGender) {\n        if (null == originalGender || UNKNOWN.getCode().equals(originalGender)) {\n            return UNKNOWN;\n        }\n        String[] males = {\"m\", \"男\", \"1\", \"male\"};\n        if (Arrays.asList(males).contains(originalGender.toLowerCase())) {\n            return MALE;\n        }\n        return FEMALE;\n    }\n\n    /**\n     * 获取微信平台用户的实际性别，0表示未定义，1表示男性，2表示女性\n     *\n     * @param originalGender 用户第三方标注的原始性别\n     * @return 用户性别\n     * @since 1.13.2\n     */\n    public static AuthUserGender getWechatRealGender(String originalGender) {\n        if (StringUtils.isEmpty(originalGender) || \"0\".equals(originalGender)) {\n            return AuthUserGender.UNKNOWN;\n        }\n        return getRealGender(originalGender);\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/enums/package-info.java",
    "content": "/**\n * 提供一些必要的枚举类\n */\npackage me.zhyd.oauth.enums;\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/enums/scope/AuthAmazonScope.java",
    "content": "package me.zhyd.oauth.enums.scope;\n\nimport lombok.AllArgsConstructor;\nimport lombok.Getter;\n\n/**\n * Amazon平台 OAuth 授权范围\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @version 1.0.0\n * @since 1.16.0\n */\n@Getter\n@AllArgsConstructor\npublic enum AuthAmazonScope implements AuthScope {\n\n    /**\n     * {@code scope} 含义，以{@code description} 为准\n     */\n    R_LITEPROFILE(\"profile\", \"The profile scope includes a user's name and email address\", true),\n    R_EMAILADDRESS(\"profile:user_id\", \"The profile:user_id scope only includes the user_id field of the profile\", true),\n    W_MEMBER_SOCIAL(\"postal_code\", \"This includes the user's zip/postal code number from their primary shipping address\", true);\n\n    private final String scope;\n    private final String description;\n    private final boolean isDefault;\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/enums/scope/AuthAppleScope.java",
    "content": "package me.zhyd.oauth.enums.scope;\n\nimport lombok.AllArgsConstructor;\nimport lombok.Getter;\n\n/**\n * @see <a href=\"https://developer.apple.com/documentation/sign_in_with_apple/clientconfigi/3230955-scope/\">scope</a>\n */\n@Getter\n@AllArgsConstructor\npublic enum AuthAppleScope implements AuthScope {\n    EMAIL(\"email\", \"用户邮箱\", true),\n    NAME(\"name\", \"用户名\", true),\n    ;\n\n    private final String scope;\n    private final String description;\n    private final boolean isDefault;\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/enums/scope/AuthBaiduScope.java",
    "content": "package me.zhyd.oauth.enums.scope;\n\nimport lombok.AllArgsConstructor;\nimport lombok.Getter;\n\n/**\n * 百度平台 OAuth 授权范围\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @version 1.0.0\n * @since 1.0.0\n */\n@Getter\n@AllArgsConstructor\npublic enum AuthBaiduScope implements AuthScope {\n\n    /**\n     * {@code scope} 含义，以{@code description} 为准\n     */\n    BASIC(\"basic\", \"用户基本权限，可以获取用户的基本信息 。\", true),\n    SUPER_MSG(\"super_msg\", \"往用户的百度首页上发送消息提醒，相关API任何应用都能使用，但要想将消息提醒在百度首页显示，需要第三方在注册应用时额外填写相关信息。\", false),\n    NETDISK(\"netdisk\", \"获取用户在个人云存储中存放的数据。\", false),\n    PUBLIC(\"public\", \"可以访问公共的开放API。\", false),\n    HAO123(\"hao123\", \"可以访问Hao123 提供的开放API接口。该权限需要申请开通，请将具体的理由和用途发邮件给tuangou@baidu.com。\", false);\n\n    private final String scope;\n    private final String description;\n    private final boolean isDefault;\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/enums/scope/AuthCodingScope.java",
    "content": "package me.zhyd.oauth.enums.scope;\n\nimport lombok.AllArgsConstructor;\nimport lombok.Getter;\n\n/**\n * Coding平台 OAuth 授权范围\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @version 1.0.0\n * @since 1.0.0\n */\n@Getter\n@AllArgsConstructor\npublic enum AuthCodingScope implements AuthScope {\n\n    /**\n     * {@code scope} 含义，以{@code description} 为准\n     */\n    USER(\"user\", \"读取用户的基本信息\", false),\n    USER_EMAIL(\"user:email\", \"读取用户的邮件\", false),\n    USER_PHONE(\"user:phone\", \"读取用户的手机号\", false),\n    PROJECT(\"project\", \"授权项目信息、项目列表，仓库信息，公钥列表、成员\", false),\n    PROJECT_DEPOT(\"project:depot\", \"完整的仓库控制权限\", false),\n    PROJECT_WIKI(\"project:wiki\", \"授权读取与操作 wiki\", false),\n    ;\n    private final String scope;\n    private final String description;\n    private final boolean isDefault;\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/enums/scope/AuthDingTalkScope.java",
    "content": "package me.zhyd.oauth.enums.scope;\n\nimport lombok.AllArgsConstructor;\nimport lombok.Getter;\n\n/**\n * 钉钉平台 OAuth 授权范围\n *\n * https://open.dingtalk.com/document/orgapp/obtain-identity-credentials#title-4up-u8w-5ug\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @version 1.0.0\n * @since 1.16.7\n */\n@Getter\n@AllArgsConstructor\npublic enum AuthDingTalkScope implements AuthScope {\n\n    /**\n     * 无需申请\t默认开启\n     */\n    openid(\"openid\", \"授权后可获得用户userid\", true),\n    /**\n     * 无需申请\t默认开启\n     */\n    corpid(\"corpid\", \"授权后可获得登录过程中用户选择的组织id\", false)\n    ;\n\n    private final String scope;\n    private final String description;\n    private final boolean isDefault;\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/enums/scope/AuthDouyinScope.java",
    "content": "package me.zhyd.oauth.enums.scope;\n\nimport lombok.AllArgsConstructor;\nimport lombok.Getter;\n\n/**\n * 抖音平台 OAuth 授权范围\n *\n * https://open.douyin.com/platform/doc/6855240178122983437\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @version 1.0.0\n * @since 1.16.1\n */\n@Getter\n@AllArgsConstructor\npublic enum AuthDouyinScope implements AuthScope {\n\n    /**\n     * 无需申请\t默认开启\n     */\n    USER_INFO(\"user_info\", \"返回抖音用户公开信息\", true),\n    /**\n     * 无需申请\t默认开启\n     */\n    AWEME_SHARE(\"aweme.share\", \"抖音分享\", false),\n    /**\n     * 普通权限,管理中心申请\n     */\n    IM_SHARE(\"im.share\", \"分享给抖音好友\", false),\n    RENEW_REFRESH_TOKEN(\"renew_refresh_token\", \"授权有效期动态续期\", false),\n    FOLLOWING_LIST(\"following.list\", \"获取该用户的关注列表\", false),\n    FANS_LIST(\"fans.list\", \"获取该用户的粉丝列表\", false),\n    VIDEO_CREATE(\"video.create\", \"视频发布及管理\", false),\n    VIDEO_DELETE(\"video.delete\", \"删除内容\", false),\n    VIDEO_DATA(\"video.data\", \"查询授权用户的抖音视频数据\", false),\n    VIDEO_LIST(\"video.list\", \"查询特定抖音视频的视频数据\", false),\n    /**\n     * 特殊权限\t默认关闭\t管理中心申请\n     */\n    SHARE_WITH_SOURCE(\"share_with_source\", \"分享携带来源标签，用户可点击标签进入转化页\", false),\n    MOBILE(\"mobile\", \"用抖音帐号登录第三方平台，获得用户在抖音上的手机号码\", false),\n    MOBILE_ALERT(\"mobile_alert\", \"用抖音帐号登录第三方平台，获得用户在抖音上的手机号码\", false),\n    VIDEO_SEARCH(\"video.search\", \"关键词视频管理\", false),\n    POI_SEARCH(\"poi.search\", \"查询POI信息\", false),\n    LOGIN_ID(\"login_id\", \"静默授权直接获取该用户的open id\", false),\n    /**\n     * 抖音数据权限, 默认关闭, 管理中心申请\n     */\n    DATA_EXTERNAL_USER(\"data.external.user\", \"查询用户的获赞、评论、分享，主页访问等相关数据\", false),\n    DATA_EXTERNAL_ITEM(\"data.external.item\", \"查询作品的获赞，评论，分享等相关数据\", false),\n    FANS_DATA(\"fans.data\", \"获取用户粉丝画像数据\", false),\n    HOTSEARCH(\"hotsearch\", \"获取抖音热门内容\", false),\n    STAR_TOP_SCORE_DISPLAY(\"star_top_score_display\", \"星图达人与达人对应各指数评估分，以及星图6大热门维度下的达人榜单\", false),\n    STAR_TOPS(\"star_tops\", \"星图达人与达人对应各指数评估分，以及星图6大热门维度下的达人榜单\", false),\n    STAR_AUTHOR_SCORE_DISPLAY(\"star_author_score_display\", \"星图达人与达人对应各指数评估分，以及星图6大热门维度下的达人榜单\", false),\n    notes(\"data.external.sdk_share\", \"获取用户通过分享SDK分享视频数据\", false),\n    /**\n     * 定向开通\t默认关闭\t定向开通\n     */\n    DISCOVERY_ENT(\"discovery.ent\", \"查询抖音电影榜、抖音剧集榜、抖音综艺榜数据\", false),\n    ;\n\n    private final String scope;\n    private final String description;\n    private final boolean isDefault;\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/enums/scope/AuthFacebookScope.java",
    "content": "package me.zhyd.oauth.enums.scope;\n\nimport lombok.AllArgsConstructor;\nimport lombok.Getter;\n\n/**\n * Facebook 平台 OAuth 授权范围\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @version 1.0.0\n * @since 1.0.0\n */\n@Getter\n@AllArgsConstructor\npublic enum AuthFacebookScope implements AuthScope {\n\n    /**\n     * {@code scope} 含义，以{@code description} 为准\n     */\n    PUBLIC_PROFILE(\"public_profile\", \"权限允许应用读取用户默认的公开资料\", true),\n    EMAIL(\"email\", \"获取用户的邮箱\", false),\n    USER_AGE_RANGE(\"user_age_range\", \"允许应用程序访问用户的年龄范围\", false),\n    USER_BIRTHDAY(\"user_birthday\", \"获取用户的生日\", false),\n    USER_FRIENDS(\"user_friends\", \"获取用户的好友列表\", false),\n    USER_GENDER(\"user_gender\", \"获取用户的性别\", false),\n    USER_HOMETOWN(\"user_hometown\", \"获取用户的家乡信息\", false),\n    USER_LIKES(\"user_likes\", \"获取用户的喜欢列表\", false),\n    USER_LINK(\"user_link\", \"获取用户的个人链接\", true),\n    USER_LOCATION(\"user_location\", \"获取用户的位置信息\", false),\n    USER_PHOTOS(\"user_photos\", \"获取用户的相册信息\", false),\n    USER_POSTS(\"user_posts\", \"获取用户发布的内容\", false),\n    USER_VIDEOS(\"user_videos\", \"获取用户上传的视频信息\", false),\n    GROUPS_ACCESS_MEMBER_INFO(\"groups_access_member_info\", \"获取公开的群组成员信息\", false),\n    PUBLISH_TO_GROUPS(\"publish_to_groups\", \"授权您的应用程序代表某人将内容发布到组中，前提是他们已经授予您的应用程序访问权限\", false),\n    ;\n\n    private final String scope;\n    private final String description;\n    private final boolean isDefault;\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/enums/scope/AuthFigmaScope.java",
    "content": "package me.zhyd.oauth.enums.scope;\n\nimport lombok.AllArgsConstructor;\nimport lombok.Getter;\n\n/**\n * Figma OAuth 授权范围\n * <a href=\"https://www.figma.com/developers/api#authentication-scopes\">...</a>\n *\n * @author xiangqian\n * @since 1.16.6\n */\n@Getter\n@AllArgsConstructor\npublic enum AuthFigmaScope implements AuthScope {\n\n    FILE_CONTENT(\"files:read\", \"Read files, projects, users, versions, comments, components & styles, and webhooks\", true),\n    VARIABLES(\"file_variables:read,file_variables:write\", \"Read and write to variables in Figma file. Note: this is only available to members in Enterprise organizations\", false),\n    COMMENTS(\"file_comments:write\", \"Post and delete comments and comment reactions in files\", false),\n    DEV_RESOURCES(\"file_dev_resources:read,file_dev_resources:write\", \"Read and write to dev resources in files\", false),\n    LIBRARY_ANALYTICS(\"library_analytics:read\", \"Read your design system analytics\", false),\n    WEBHOOKS(\"webhooks:write\", \"Create and manage webhooks\", false);\n\n    private final String scope;\n    private final String description;\n    private final boolean isDefault;\n\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/enums/scope/AuthGiteeScope.java",
    "content": "package me.zhyd.oauth.enums.scope;\n\nimport lombok.AllArgsConstructor;\nimport lombok.Getter;\n\n/**\n * Gitee 平台 OAuth 授权范围\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @version 1.0.0\n * @since 1.0.0\n */\n@Getter\n@AllArgsConstructor\npublic enum AuthGiteeScope implements AuthScope {\n\n    /**\n     * {@code scope} 含义，以{@code description} 为准\n     */\n    USER_INFO(\"user_info\", \"访问用户的个人信息、最新动态等\", true),\n    PROJECTS(\"projects\", \"查看、创建、更新用户的项目\", false),\n    PULL_REQUESTS(\"pull_requests\", \"查看、发布、更新用户的 Pull Request\", false),\n    ISSUES(\"issues\", \"查看、发布、更新用户的 Issue\", false),\n    NOTES(\"notes\", \"查看、发布、管理用户在项目、代码片段中的评论\", false),\n    KEYS(\"keys\", \"查看、部署、删除用户的公钥\", false),\n    HOOK(\"hook\", \"查看、部署、更新用户的 Webhook\", false),\n    GROUPS(\"groups\", \"查看、管理用户的组织以及成员\", false),\n    GISTS(\"gists\", \"查看、删除、更新用户的代码片段\", false),\n    ENTERPRISES(\"enterprises\", \"查看、管理用户的企业以及成员\", false),\n    EMAILS(\"emails\", \"查看用户的个人邮箱信息\", false);\n\n    private final String scope;\n    private final String description;\n    private final boolean isDefault;\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/enums/scope/AuthGithubScope.java",
    "content": "package me.zhyd.oauth.enums.scope;\n\nimport lombok.AllArgsConstructor;\nimport lombok.Getter;\n\n/**\n * Github平台 OAuth 授权范围\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @version 1.0.0\n * @since 1.0.0\n */\n@Getter\n@AllArgsConstructor\npublic enum AuthGithubScope implements AuthScope {\n\n    /**\n     * {@code scope} 含义，以{@code description} 为准\n     */\n    REPO_STATUS(\"repo:status\", \"Grants read/write access to public and private repository commit statuses. This scope is only necessary to grant other users or services access to private repository commit statuses <em>without</em> granting access to the code.\", false),\n    REPO_DEPLOYMENT(\"repo_deployment\", \"Grants access to deployment statuses for public and private repositories. This scope is only necessary to grant other users or services access to deployment statuses, <em>without</em> granting access to the code.\", false),\n    PUBLIC_REPO(\"public_repo\", \"Limits access to public repositories. That includes read/write access to code, commit statuses, repository projects, collaborators, and deployment statuses for public repositories and organizations. Also required for starring public repositories.\", false),\n    REPO_INVITE(\"repo:invite\", \"Grants accept/decline abilities for invitations to collaborate on a repository. This scope is only necessary to grant other users or services access to invites <em>without</em> granting access to the code.\", false),\n    SECURITY_EVENTS(\"security_events\", \"Grants read and write access to security events in the code scanning API.\", false),\n    WRITE_REPO_HOOK(\"write:repo_hook\", \"Grants read, write, and ping access to hooks in public or private repositories.\", false),\n    READ_REPO_HOOK(\"read:repo_hook\", \"Grants read and ping access to hooks in public or private repositories.\", false),\n    ADMIN_ORG(\"admin:org\", \"Fully manage the organization and its teams, projects, and memberships.\", false),\n    WRITE_ORG(\"write:org\", \"Read and write access to organization membership, organization projects, and team membership.\", false),\n    READ_ORG(\"read:org\", \"Read-only access to organization membership, organization projects, and team membership.\", false),\n    ADMIN_PUBLIC_KEY(\"admin:public_key\", \"Fully manage public keys.\", false),\n    WRITE_PUBLIC_KEY(\"write:public_key\", \"Create, list, and view details for public keys.\", false),\n    READ_PUBLIC_KEY(\"read:public_key\", \"List and view details for public keys.\", false),\n    GIST(\"gist\", \"Grants write access to gists.\", false),\n    NOTIFICATIONS(\"notifications\", \"Grants: <br>* read access to a user's notifications <br>* mark as read access to threads <br>* watch and unwatch access to a repository, and <br>* read, write, and delete access to thread subscriptions.\", false),\n    USER(\"user\", \"Grants read/write access to profile info only.  Note that this scope includes <code>user:email</code> and <code>user:follow</code>.\", false),\n    READ_USER(\"read:user\", \"Grants access to read a user's profile data.\", false),\n    USER_EMAIL(\"user:email\", \"Grants read access to a user's email addresses.\", false),\n    USER_FOLLOW(\"user:follow\", \"Grants access to follow or unfollow other users.\", false),\n    DELETE_REPO(\"delete_repo\", \"Grants access to delete adminable repositories.\", false),\n    WRITE_DISCUSSION(\"write:discussion\", \"Allows read and write access for team discussions.\", false),\n    READ_DISCUSSION(\"read:discussion\", \"Allows read access for team discussions.\", false),\n    WRITE_PACKAGES(\"write:packages\", \"Grants access to upload or publish a package in GitHub Packages. For more information, see \\\"<a href=\\\"https://help.github.com/github/managing-packages-with-github-packages/publishing-a-package\\\">Publishing a package</a>\\\" in the GitHub Help documentation.\", false),\n    READ_PACKAGES(\"read:packages\", \"Grants access to download or install packages from GitHub Packages. For more information, see \\\"<a href=\\\"https://help.github.com/github/managing-packages-with-github-packages/installing-a-package\\\">Installing a package</a>\\\" in the GitHub Help documentation.\", false),\n    DELETE_PACKAGES(\"delete:packages\", \"Grants access to delete packages from GitHub Packages. For more information, see \\\"<a href=\\\"https://help.github.com/github/managing-packages-with-github-packages/deleting-a-package\\\">Deleting packages</a>\\\" in the GitHub Help documentation.\", false),\n    ADMIN_GPG_KEY(\"admin:gpg_key\", \"Fully manage GPG keys.\", false),\n    WRITE_GPG_KEY(\"write:gpg_key\", \"Create, list, and view details for GPG keys.\", false),\n    READ_GPG_KEY(\"read:gpg_key\", \"List and view details for GPG keys.\", false),\n    WORKFLOW(\"workflow\", \"Grants the ability to add and update GitHub Actions workflow files. Workflow files can be committed without this scope if the same file (with both the same path and contents) exists on another branch in the same repository.\", false),\n    ;\n    private final String scope;\n    private final String description;\n    private final boolean isDefault;\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/enums/scope/AuthGitlabScope.java",
    "content": "package me.zhyd.oauth.enums.scope;\n\nimport lombok.AllArgsConstructor;\nimport lombok.Getter;\n\n/**\n * Gitlab 平台 OAuth 授权范围\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @version 1.0.0\n * @since 1.0.0\n */\n@Getter\n@AllArgsConstructor\npublic enum AuthGitlabScope implements AuthScope {\n\n    /**\n     * {@code scope} 含义，以{@code description} 为准\n     */\n    READ_USER(\"read_user\", \"Grants read-only access to the authenticated user's profile through the /user API endpoint, which includes username, public email, and full name. Also grants access to read-only API endpoints under /users.\", true),\n    OPENID(\"openid\", \"Grants permission to authenticate with GitLab using OpenID Connect. Also gives read-only access to the user's profile and group memberships.\", true),\n    PROFILE(\"profile\", \"Grants read-only access to the user's profile data using OpenID Connect.\", true),\n    EMAIL(\"email\", \"Grants read-only access to the user's primary email address using OpenID Connect.\", true),\n    READ_API(\"read_api\", \"Grants read access to the API, including all groups and projects, the container registry, and the package registry.\", false),\n    READ_REPOSITORY(\"read_repository\", \"Grants read-only access to repositories on private projects using Git-over-HTTP or the Repository Files API.\", false),\n    WRITE_REPOSITORY(\"write_repository\", \"Grants read-write access to repositories on private projects using Git-over-HTTP (not using the API).\", false),\n    READ_REGISTRY(\"read_registry\", \"Grants read-only access to container registry images on private projects.\", false),\n    WRITE_REGISTRY(\"write_registry\", \"<span title=\\\"translation missing: en.doorkeeper.scope_desc.write_registry\\\">Write Registry</span>\", false),\n    SUDO(\"sudo\", \"Grants permission to perform API actions as any user in the system, when authenticated as an admin user.\", false),\n    API(\"api\", \"Grants complete read/write access to the API, including all groups and projects, the container registry, and the package registry.\", false),\n    ;\n\n    private final String scope;\n    private final String description;\n    private final boolean isDefault;\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/enums/scope/AuthGoogleScope.java",
    "content": "package me.zhyd.oauth.enums.scope;\n\nimport lombok.AllArgsConstructor;\nimport lombok.Getter;\n\nimport java.util.Arrays;\nimport java.util.List;\nimport java.util.stream.Collectors;\n\n/**\n * Google 平台 OAuth 授权范围\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @version 1.0.0\n * @since 1.0.0\n */\n@Getter\n@AllArgsConstructor\npublic enum AuthGoogleScope implements AuthScope {\n\n    /**\n     * {@code scope} 含义，以{@code description} 为准\n     */\n    USER_OPENID(\"openid\", \"Associate you with your personal info on Google\", true),\n    USER_EMAIL(\"email\", \"View your email address\", true),\n    USER_PROFILE(\"profile\", \"View your basic profile info\", true),\n    USER_PHONENUMBERS_READ(\"https://www.googleapis.com/auth/user.phonenumbers.read\", \"View your phone numbers\", false),\n    USER_ORGANIZATION_READ(\"https://www.googleapis.com/auth/user.organization.read\", \"See your education, work history and org info\", false),\n    USER_GENDER_READ(\"https://www.googleapis.com/auth/user.gender.read\", \"See your gender\", false),\n    USER_EMAILS_READ(\"https://www.googleapis.com/auth/user.emails.read\", \"View your email addresses\", false),\n    USER_BIRTHDAY_READ(\"https://www.googleapis.com/auth/user.birthday.read\", \"View your complete date of birth\", false),\n    USER_ADDRESSES_READ(\"https://www.googleapis.com/auth/user.addresses.read\", \"View your street addresses\", false),\n    USERINFO_PROFILE(\"https://www.googleapis.com/auth/userinfo.profile\", \"See your personal info, including any personal info you've made publicly available\", false),\n    USERINFO_EMAIL(\"https://www.googleapis.com/auth/userinfo.email\", \"View your email address\", false),\n    YT_ANALYTICS_READONLY(\"https://www.googleapis.com/auth/yt-analytics.readonly\", \"View YouTube Analytics reports for your YouTube content\", false),\n    YT_ANALYTICS_MONETARY_READONLY(\"https://www.googleapis.com/auth/yt-analytics-monetary.readonly\", \"View monetary and non-monetary YouTube Analytics reports for your YouTube content\", false),\n    YOUTUBEPARTNER_CHANNEL_AUDIT(\"https://www.googleapis.com/auth/youtubepartner-channel-audit\", \"View private information of your YouTube channel relevant during the audit process with a YouTube partner\", false),\n    YOUTUBEPARTNER(\"https://www.googleapis.com/auth/youtubepartner\", \"View and manage your assets and associated content on YouTube\", false),\n    YOUTUBE_UPLOAD(\"https://www.googleapis.com/auth/youtube.upload\", \"Manage your YouTube videos\", false),\n    YOUTUBE_READONLY(\"https://www.googleapis.com/auth/youtube.readonly\", \"View your YouTube account\", false),\n    YOUTUBE_FORCE_SSL(\"https://www.googleapis.com/auth/youtube.force-ssl\", \"See, edit, and permanently delete your YouTube videos, ratings, comments and captions\", false),\n    YOUTUBE_CHANNEL_MEMBERSHIPS_CREATOR(\"https://www.googleapis.com/auth/youtube.channel-memberships.creator\", \"See a list of your current active channel members, their current level, and when they became a member\", false),\n    YOUTUBE(\"https://www.googleapis.com/auth/youtube\", \"Manage your YouTube account\", false),\n    WEBMASTERS_READONLY(\"https://www.googleapis.com/auth/webmasters.readonly\", \"View Search Console data for your verified sites\", false),\n    WEBMASTERS(\"https://www.googleapis.com/auth/webmasters\", \"View and manage Search Console data for your verified sites\", false),\n    VERIFIEDACCESS(\"https://www.googleapis.com/auth/verifiedaccess\", \"Verify your enterprise credentials\", false),\n    TRACE_APPEND(\"https://www.googleapis.com/auth/trace.append\", \"Write Trace data for a project or application\", false),\n    TASKS_READONLY(\"https://www.googleapis.com/auth/tasks.readonly\", \"View your tasks\", false),\n    TASKS(\"https://www.googleapis.com/auth/tasks\", \"Create, edit, organize, and delete all your tasks\", false),\n    TAGMANAGER_READONLY(\"https://www.googleapis.com/auth/tagmanager.readonly\", \"View your Google Tag Manager container and its subcomponents\", false),\n    TAGMANAGER_PUBLISH(\"https://www.googleapis.com/auth/tagmanager.publish\", \"Publish your Google Tag Manager container versions\", false),\n    TAGMANAGER_MANAGE_USERS(\"https://www.googleapis.com/auth/tagmanager.manage.users\", \"Manage user permissions of your Google Tag Manager account and container\", false),\n    TAGMANAGER_MANAGE_ACCOUNTS(\"https://www.googleapis.com/auth/tagmanager.manage.accounts\", \"View and manage your Google Tag Manager accounts\", false),\n    TAGMANAGER_EDIT_CONTAINERVERSIONS(\"https://www.googleapis.com/auth/tagmanager.edit.containerversions\", \"Manage your Google Tag Manager container versions\", false),\n    TAGMANAGER_EDIT_CONTAINERS(\"https://www.googleapis.com/auth/tagmanager.edit.containers\", \"Manage your Google Tag Manager container and its subcomponents, excluding versioning and publishing\", false),\n    TAGMANAGER_DELETE_CONTAINERS(\"https://www.googleapis.com/auth/tagmanager.delete.containers\", \"Delete your Google Tag Manager containers\", false),\n    STREETVIEWPUBLISH(\"https://www.googleapis.com/auth/streetviewpublish\", \"Publish and manage your 360 photos on Google Street View\", false),\n    SQLSERVICE_ADMIN(\"https://www.googleapis.com/auth/sqlservice.admin\", \"Manage your Google SQL Service instances\", false),\n    SPREADSHEETS_READONLY(\"https://www.googleapis.com/auth/spreadsheets.readonly\", \"View your Google Spreadsheets\", false),\n    SPREADSHEETS(\"https://www.googleapis.com/auth/spreadsheets\", \"See, edit, create, and delete your spreadsheets in Google Drive\", false),\n    SPANNER_DATA(\"https://www.googleapis.com/auth/spanner.data\", \"View and manage the contents of your Spanner databases\", false),\n    SPANNER_ADMIN(\"https://www.googleapis.com/auth/spanner.admin\", \"Administer your Spanner databases\", false),\n    SOURCE_READ_WRITE(\"https://www.googleapis.com/auth/source.read_write\", \"Manage the contents of your source code repositories\", false),\n    SOURCE_READ_ONLY(\"https://www.googleapis.com/auth/source.read_only\", \"View the contents of your source code repositories\", false),\n    SOURCE_FULL_CONTROL(\"https://www.googleapis.com/auth/source.full_control\", \"Manage your source code repositories\", false),\n    SITEVERIFICATION_VERIFY_ONLY(\"https://www.googleapis.com/auth/siteverification.verify_only\", \"Manage your new site verifications with Google\", false),\n    SITEVERIFICATION(\"https://www.googleapis.com/auth/siteverification\", \"Manage the list of sites and domains you control\", false),\n    SERVICECONTROL(\"https://www.googleapis.com/auth/servicecontrol\", \"Manage your Google Service Control data\", false),\n    SERVICE_MANAGEMENT_READONLY(\"https://www.googleapis.com/auth/service.management.readonly\", \"View your Google API service configuration\", false),\n    SERVICE_MANAGEMENT(\"https://www.googleapis.com/auth/service.management\", \"Manage your Google API service configuration\", false),\n    SCRIPT_PROJECTS_READONLY(\"https://www.googleapis.com/auth/script.projects.readonly\", \"View Google Apps Script projects\", false),\n    SCRIPT_PROJECTS(\"https://www.googleapis.com/auth/script.projects\", \"Create and update Google Apps Script projects\", false),\n    SCRIPT_PROCESSES(\"https://www.googleapis.com/auth/script.processes\", \"View Google Apps Script processes\", false),\n    SCRIPT_METRICS(\"https://www.googleapis.com/auth/script.metrics\", \"View Google Apps Script project's metrics\", false),\n    SCRIPT_DEPLOYMENTS_READONLY(\"https://www.googleapis.com/auth/script.deployments.readonly\", \"View Google Apps Script deployments\", false),\n    SCRIPT_DEPLOYMENTS(\"https://www.googleapis.com/auth/script.deployments\", \"Create and update Google Apps Script deployments\", false),\n    PUBSUB(\"https://www.googleapis.com/auth/pubsub\", \"View and manage Pub/Sub topics and subscriptions\", false),\n    PRESENTATIONS_READONLY(\"https://www.googleapis.com/auth/presentations.readonly\", \"View your Google Slides presentations\", false),\n    PRESENTATIONS(\"https://www.googleapis.com/auth/presentations\", \"View and manage your Google Slides presentations\", false),\n    PHOTOSLIBRARY_SHARING(\"https://www.googleapis.com/auth/photoslibrary.sharing\", \"Manage and add to shared albums on your behalf\", false),\n    PHOTOSLIBRARY_READONLY_APPCREATEDDATA(\"https://www.googleapis.com/auth/photoslibrary.readonly.appcreateddata\", \"Manage photos added by this app\", false),\n    PHOTOSLIBRARY_READONLY(\"https://www.googleapis.com/auth/photoslibrary.readonly\", \"View your Google Photos library\", false),\n    PHOTOSLIBRARY_APPENDONLY(\"https://www.googleapis.com/auth/photoslibrary.appendonly\", \"Add to your Google Photos library\", false),\n    PHOTOSLIBRARY(\"https://www.googleapis.com/auth/photoslibrary\", \"View and manage your Google Photos library\", false),\n    NDEV_CLOUDMAN_READONLY(\"https://www.googleapis.com/auth/ndev.cloudman.readonly\", \"View your Google Cloud Platform management resources and deployment status information\", false),\n    NDEV_CLOUDMAN(\"https://www.googleapis.com/auth/ndev.cloudman\", \"View and manage your Google Cloud Platform management resources and deployment status information\", false),\n    NDEV_CLOUDDNS_READWRITE(\"https://www.googleapis.com/auth/ndev.clouddns.readwrite\", \"View and manage your DNS records hosted by Google Cloud DNS\", false),\n    NDEV_CLOUDDNS_READONLY(\"https://www.googleapis.com/auth/ndev.clouddns.readonly\", \"View your DNS records hosted by Google Cloud DNS\", false),\n    MONITORING_WRITE(\"https://www.googleapis.com/auth/monitoring.write\", \"Publish metric data to your Google Cloud projects\", false),\n    MONITORING_READ(\"https://www.googleapis.com/auth/monitoring.read\", \"View monitoring data for all of your Google Cloud and third-party projects\", false),\n    MONITORING(\"https://www.googleapis.com/auth/monitoring\", \"View and write monitoring data for all of your Google and third-party Cloud and API projects\", false),\n    MANUFACTURERCENTER(\"https://www.googleapis.com/auth/manufacturercenter\", \"Manage your product listings for Google Manufacturer Center\", false),\n    LOGGING_WRITE(\"https://www.googleapis.com/auth/logging.write\", \"Submit log data for your projects\", false),\n    LOGGING_READ(\"https://www.googleapis.com/auth/logging.read\", \"View log data for your projects\", false),\n    LOGGING_ADMIN(\"https://www.googleapis.com/auth/logging.admin\", \"Administrate log data for your projects\", false),\n    JOBS(\"https://www.googleapis.com/auth/jobs\", \"Manage job postings\", false),\n    INDEXING(\"https://www.googleapis.com/auth/indexing\", \"Submit data to Google for indexing\", false),\n    GROUPS(\"https://www.googleapis.com/auth/groups\", \"View and manage your Google Groups\", false),\n    GMAIL(\"https://mail.google.com/\", \"Read, compose, send, and permanently delete all your email from Gmail\", false),\n    GMAIL_SETTINGS_SHARING(\"https://www.googleapis.com/auth/gmail.settings.sharing\", \"Manage your sensitive mail settings, including who can manage your mail\", false),\n    GMAIL_SETTINGS_BASIC(\"https://www.googleapis.com/auth/gmail.settings.basic\", \"Manage your basic mail settings\", false),\n    GMAIL_SEND(\"https://www.googleapis.com/auth/gmail.send\", \"Send email on your behalf\", false),\n    GMAIL_READONLY(\"https://www.googleapis.com/auth/gmail.readonly\", \"View your email messages and settings\", false),\n    GMAIL_MODIFY(\"https://www.googleapis.com/auth/gmail.modify\", \"View and modify but not delete your email\", false),\n    GMAIL_METADATA(\"https://www.googleapis.com/auth/gmail.metadata\", \"View your email message metadata such as labels and headers, but not the email body\", false),\n    GMAIL_LABELS(\"https://www.googleapis.com/auth/gmail.labels\", \"Manage mailbox labels\", false),\n    GMAIL_INSERT(\"https://www.googleapis.com/auth/gmail.insert\", \"Insert mail into your mailbox\", false),\n    GMAIL_COMPOSE(\"https://www.googleapis.com/auth/gmail.compose\", \"Manage drafts and send emails\", false),\n    GMAIL_ADDONS_CURRENT_MESSAGE_READONLY(\"https://www.googleapis.com/auth/gmail.addons.current.message.readonly\", \"View your email messages when the add-on is running\", false),\n    GMAIL_ADDONS_CURRENT_MESSAGE_METADATA(\"https://www.googleapis.com/auth/gmail.addons.current.message.metadata\", \"View your email message metadata when the add-on is running\", false),\n    GMAIL_ADDONS_CURRENT_MESSAGE_ACTION(\"https://www.googleapis.com/auth/gmail.addons.current.message.action\", \"View your email messages when you interact with the add-on\", false),\n    GMAIL_ADDONS_CURRENT_ACTION_COMPOSE(\"https://www.googleapis.com/auth/gmail.addons.current.action.compose\", \"Manage drafts and send emails when you interact with the add-on\", false),\n    GENOMICS(\"https://www.googleapis.com/auth/genomics\", \"View and manage Genomics data\", false),\n    GAMES(\"https://www.googleapis.com/auth/games\", \"Create, edit, and delete your Google Play Games activity\", false),\n    FORMS_CURRENTONLY(\"https://www.googleapis.com/auth/forms.currentonly\", \"View and manage forms that this application has been installed in\", false),\n    FORMS(\"https://www.googleapis.com/auth/forms\", \"View and manage your forms in Google Drive\", false),\n    FITNESS_REPRODUCTIVE_HEALTH_WRITE(\"https://www.googleapis.com/auth/fitness.reproductive_health.write\", \"See and add info about your reproductive health in Google Fit. I consent to Google sharing my reporductive health information with this app.\", false),\n    FITNESS_REPRODUCTIVE_HEALTH_READ(\"https://www.googleapis.com/auth/fitness.reproductive_health.read\", \"See info about your reproductive health in Google Fit. I consent to Google sharing my reporductive health information with this app.\", false),\n    FITNESS_OXYGEN_SATURATION_WRITE(\"https://www.googleapis.com/auth/fitness.oxygen_saturation.write\", \"See and add info about your oxygen saturation in Google Fit. I consent to Google sharing my oxygen saturation information with this app.\", false),\n    FITNESS_OXYGEN_SATURATION_READ(\"https://www.googleapis.com/auth/fitness.oxygen_saturation.read\", \"See info about your oxygen saturation in Google Fit. I consent to Google sharing my oxygen saturation information with this app.\", false),\n    FITNESS_NUTRITION_WRITE(\"https://www.googleapis.com/auth/fitness.nutrition.write\", \"See and add to info about your nutrition in Google Fit\", false),\n    FITNESS_NUTRITION_READ(\"https://www.googleapis.com/auth/fitness.nutrition.read\", \"See info about your nutrition in Google Fit\", false),\n    FITNESS_LOCATION_WRITE(\"https://www.googleapis.com/auth/fitness.location.write\", \"See and add to your Google Fit location data\", false),\n    FITNESS_LOCATION_READ(\"https://www.googleapis.com/auth/fitness.location.read\", \"See your Google Fit speed and distance data\", false),\n    FITNESS_BODY_TEMPERATURE_WRITE(\"https://www.googleapis.com/auth/fitness.body_temperature.write\", \"See and add to info about your body temperature in Google Fit. I consent to Google sharing my body temperature information with this app.\", false),\n    FITNESS_BODY_TEMPERATURE_READ(\"https://www.googleapis.com/auth/fitness.body_temperature.read\", \"See info about your body temperature in Google Fit. I consent to Google sharing my body temperature information with this app.\", false),\n    FITNESS_BODY_WRITE(\"https://www.googleapis.com/auth/fitness.body.write\", \"See and add info about your body measurements and heart rate to Google Fit\", false),\n    FITNESS_BODY_READ(\"https://www.googleapis.com/auth/fitness.body.read\", \"See info about your body measurements and heart rate in Google Fit\", false),\n    FITNESS_BLOOD_PRESSURE_WRITE(\"https://www.googleapis.com/auth/fitness.blood_pressure.write\", \"See and add info about your blood pressure in Google Fit. I consent to Google sharing my blood pressure information with this app.\", false),\n    FITNESS_BLOOD_PRESSURE_READ(\"https://www.googleapis.com/auth/fitness.blood_pressure.read\", \"See info about your blood pressure in Google Fit. I consent to Google sharing my blood pressure information with this app.\", false),\n    FITNESS_BLOOD_GLUCOSE_WRITE(\"https://www.googleapis.com/auth/fitness.blood_glucose.write\", \"See and add info about your blood glucose to Google Fit. I consent to Google sharing my blood glucose information with this app.\", false),\n    FITNESS_BLOOD_GLUCOSE_READ(\"https://www.googleapis.com/auth/fitness.blood_glucose.read\", \"See info about your blood glucose in Google Fit. I consent to Google sharing my blood glucose information with this app.\", false),\n    FITNESS_ACTIVITY_WRITE(\"https://www.googleapis.com/auth/fitness.activity.write\", \"See and add to your Google Fit physical activity data\", false),\n    FITNESS_ACTIVITY_READ(\"https://www.googleapis.com/auth/fitness.activity.read\", \"Use Google Fit to see and store your physical activity data\", false),\n    FIREBASE_READONLY(\"https://www.googleapis.com/auth/firebase.readonly\", \"View all your Firebase data and settings\", false),\n    FIREBASE(\"https://www.googleapis.com/auth/firebase\", \"View and administer all your Firebase data and settings\", false),\n    EDISCOVERY_READONLY(\"https://www.googleapis.com/auth/ediscovery.readonly\", \"View your eDiscovery data\", false),\n    EDISCOVERY(\"https://www.googleapis.com/auth/ediscovery\", \"Manage your eDiscovery data\", false),\n    DRIVE_SCRIPTS(\"https://www.googleapis.com/auth/drive.scripts\", \"Modify your Google Apps Script scripts' behavior\", false),\n    DRIVE_READONLY(\"https://www.googleapis.com/auth/drive.readonly\", \"See and download all your Google Drive files\", false),\n    DRIVE_PHOTOS_READONLY(\"https://www.googleapis.com/auth/drive.photos.readonly\", \"View the photos, videos and albums in your Google Photos\", false),\n    DRIVE_METADATA_READONLY(\"https://www.googleapis.com/auth/drive.metadata.readonly\", \"View metadata for files in your Google Drive\", false),\n    DRIVE_METADATA(\"https://www.googleapis.com/auth/drive.metadata\", \"View and manage metadata of files in your Google Drive\", false),\n    DRIVE_FILE(\"https://www.googleapis.com/auth/drive.file\", \"View and manage Google Drive files and folders that you have opened or created with this app\", false),\n    DRIVE_APPDATA(\"https://www.googleapis.com/auth/drive.appdata\", \"View and manage its own configuration data in your Google Drive\", false),\n    DRIVE_ACTIVITY_READONLY(\"https://www.googleapis.com/auth/drive.activity.readonly\", \"View the activity record of files in your Google Drive\", false),\n    DRIVE_ACTIVITY(\"https://www.googleapis.com/auth/drive.activity\", \"View and add to the activity record of files in your Google Drive\", false),\n    DRIVE(\"https://www.googleapis.com/auth/drive\", \"See, edit, create, and delete all of your Google Drive files\", false),\n    ACTIVITY(\"https://www.googleapis.com/auth/activity\", \"View the activity history of your Google apps\", false),\n    DOUBLECLICKSEARCH(\"https://www.googleapis.com/auth/doubleclicksearch\", \"View and manage your advertising data in DoubleClick Search\", false),\n    DOUBLECLICKBIDMANAGER(\"https://www.googleapis.com/auth/doubleclickbidmanager\", \"View and manage your reports in DoubleClick Bid Manager\", false),\n    DOCUMENTS_READONLY(\"https://www.googleapis.com/auth/documents.readonly\", \"View your Google Docs documents\", false),\n    DOCUMENTS(\"https://www.googleapis.com/auth/documents\", \"View and manage your Google Docs documents\", false),\n    DISPLAY_VIDEO(\"https://www.googleapis.com/auth/display-video\", \"Create, see, edit, and permanently delete your Display & Video 360 entities and reports\", false),\n    DIRECTORY_READONLY(\"https://www.googleapis.com/auth/directory.readonly\", \"See and download your organization's GSuite directory\", false),\n    DIALOGFLOW(\"https://www.googleapis.com/auth/dialogflow\", \"View, manage and query your Dialogflow agents\", false),\n    DFATRAFFICKING(\"https://www.googleapis.com/auth/dfatrafficking\", \"View and manage your DoubleClick Campaign Manager's (DCM) display ad campaigns\", false),\n    DFAREPORTING(\"https://www.googleapis.com/auth/dfareporting\", \"View and manage DoubleClick for Advertisers reports\", false),\n    DEVSTORAGE_READ_WRITE(\"https://www.googleapis.com/auth/devstorage.read_write\", \"Manage your data in Google Cloud Storage\", false),\n    DEVSTORAGE_READ_ONLY(\"https://www.googleapis.com/auth/devstorage.read_only\", \"View your data in Google Cloud Storage\", false),\n    DEVSTORAGE_FULL_CONTROL(\"https://www.googleapis.com/auth/devstorage.full_control\", \"Manage your data and permissions in Google Cloud Storage\", false),\n    DDMCONVERSIONS(\"https://www.googleapis.com/auth/ddmconversions\", \"Manage DoubleClick Digital Marketing conversions\", false),\n    DATASTORE(\"https://www.googleapis.com/auth/datastore\", \"View and manage your Google Cloud Datastore data\", false),\n    CONTENT(\"https://www.googleapis.com/auth/content\", \"Manage your product listings and accounts for Google Shopping\", false),\n    CONTACTS_READONLY(\"https://www.googleapis.com/auth/contacts.readonly\", \"See and download your contacts\", false),\n    CONTACTS_OTHER_READONLY(\"https://www.googleapis.com/auth/contacts.other.readonly\", \"See and download contact info automatically saved in your \\\"Other contacts\\\"\", false),\n    CONTACTS(\"https://www.googleapis.com/auth/contacts\", \"See, edit, download, and permanently delete your contacts\", false),\n    CONTACTS_FEEDS(\"https://www.google.com/m8/feeds\", \"See, edit, download, and permanently delete your contacts\", false),\n    COMPUTE_READONLY(\"https://www.googleapis.com/auth/compute.readonly\", \"View your Google Compute Engine resources\", false),\n    COMPUTE(\"https://www.googleapis.com/auth/compute\", \"View and manage your Google Compute Engine resources\", false),\n    CLOUDRUNTIMECONFIG(\"https://www.googleapis.com/auth/cloudruntimeconfig\", \"Manage your Google Cloud Platform services' runtime configuration\", false),\n    CLOUDKMS(\"https://www.googleapis.com/auth/cloudkms\", \"View and manage your keys and secrets stored in Cloud Key Management Service\", false),\n    CLOUDIOT(\"https://www.googleapis.com/auth/cloudiot\", \"Register and manage devices in the Google Cloud IoT service\", false),\n    CLOUD_SEARCH_STATS_INDEXING(\"https://www.googleapis.com/auth/cloud_search.stats.indexing\", \"Index and serve your organization's data with Cloud Search\", false),\n    CLOUD_SEARCH_STATS(\"https://www.googleapis.com/auth/cloud_search.stats\", \"Index and serve your organization's data with Cloud Search\", false),\n    CLOUD_SEARCH_SETTINGS_QUERY(\"https://www.googleapis.com/auth/cloud_search.settings.query\", \"Index and serve your organization's data with Cloud Search\", false),\n    CLOUD_SEARCH_SETTINGS_INDEXING(\"https://www.googleapis.com/auth/cloud_search.settings.indexing\", \"Index and serve your organization's data with Cloud Search\", false),\n    CLOUD_SEARCH_SETTINGS(\"https://www.googleapis.com/auth/cloud_search.settings\", \"Index and serve your organization's data with Cloud Search\", false),\n    CLOUD_SEARCH_QUERY(\"https://www.googleapis.com/auth/cloud_search.query\", \"Search your organization's data in the Cloud Search index\", false),\n    CLOUD_SEARCH_INDEXING(\"https://www.googleapis.com/auth/cloud_search.indexing\", \"Index and serve your organization's data with Cloud Search\", false),\n    CLOUD_SEARCH_DEBUG(\"https://www.googleapis.com/auth/cloud_search.debug\", \"Index and serve your organization's data with Cloud Search\", false),\n    CLOUD_SEARCH(\"https://www.googleapis.com/auth/cloud_search\", \"Index and serve your organization's data with Cloud Search\", false),\n    CLOUD_DEBUGGER(\"https://www.googleapis.com/auth/cloud_debugger\", \"Use Stackdriver Debugger\", false),\n    CLOUD_VISION(\"https://www.googleapis.com/auth/cloud-vision\", \"Apply machine learning models to understand and label images\", false),\n    CLOUD_TRANSLATION(\"https://www.googleapis.com/auth/cloud-translation\", \"Translate text from one language to another using Google Translate\", false),\n    CLOUD_PLATFORM_READ_ONLY(\"https://www.googleapis.com/auth/cloud-platform.read-only\", \"View your data across Google Cloud Platform services\", false),\n    CLOUD_PLATFORM(\"https://www.googleapis.com/auth/cloud-platform\", \"View and manage your data across Google Cloud Platform services\", false),\n    CLOUD_LANGUAGE(\"https://www.googleapis.com/auth/cloud-language\", \"Apply machine learning models to reveal the structure and meaning of text\", false),\n    CLOUD_IDENTITY_GROUPS_READONLY(\"https://www.googleapis.com/auth/cloud-identity.groups.readonly\", \"See any Cloud Identity Groups that you can access, including group members and their emails\", false),\n    CLOUD_IDENTITY_GROUPS(\"https://www.googleapis.com/auth/cloud-identity.groups\", \"See, change, create, and delete any of the Cloud Identity Groups that you can access, including the members of each group\", false),\n    CLOUD_BIGTABLE_ADMIN_TABLE(\"https://www.googleapis.com/auth/cloud-bigtable.admin.table\", \"Administer your Cloud Bigtable tables\", false),\n    CLOUD_BIGTABLE_ADMIN_CLUSTER(\"https://www.googleapis.com/auth/cloud-bigtable.admin.cluster\", \"Administer your Cloud Bigtable clusters\", false),\n    CLOUD_BIGTABLE_ADMIN(\"https://www.googleapis.com/auth/cloud-bigtable.admin\", \"Administer your Cloud Bigtable tables and clusters\", false),\n    CLASSROOM_TOPICS_READONLY(\"https://www.googleapis.com/auth/classroom.topics.readonly\", \"View topics in Google Classroom\", false),\n    CLASSROOM_TOPICS(\"https://www.googleapis.com/auth/classroom.topics\", \"See, create, and edit topics in Google Classroom\", false),\n    CLASSROOM_STUDENT_SUBMISSIONS_STUDENTS_READONLY(\"https://www.googleapis.com/auth/classroom.student-submissions.students.readonly\", \"View course work and grades for students in the Google Classroom classes you teach or administer\", false),\n    CLASSROOM_STUDENT_SUBMISSIONS_ME_READONLY(\"https://www.googleapis.com/auth/classroom.student-submissions.me.readonly\", \"View your course work and grades in Google Classroom\", false),\n    CLASSROOM_ROSTERS_READONLY(\"https://www.googleapis.com/auth/classroom.rosters.readonly\", \"View your Google Classroom class rosters\", false),\n    CLASSROOM_ROSTERS(\"https://www.googleapis.com/auth/classroom.rosters\", \"Manage your Google Classroom class rosters\", false),\n    CLASSROOM_PUSH_NOTIFICATIONS(\"https://www.googleapis.com/auth/classroom.push-notifications\", \"Receive notifications about your Google Classroom data\", false),\n    CLASSROOM_PROFILE_PHOTOS(\"https://www.googleapis.com/auth/classroom.profile.photos\", \"View the profile photos of people in your classes\", false),\n    CLASSROOM_PROFILE_EMAILS(\"https://www.googleapis.com/auth/classroom.profile.emails\", \"View the email addresses of people in your classes\", false),\n    CLASSROOM_GUARDIANLINKS_STUDENTS_READONLY(\"https://www.googleapis.com/auth/classroom.guardianlinks.students.readonly\", \"View guardians for students in your Google Classroom classes\", false),\n    CLASSROOM_GUARDIANLINKS_STUDENTS(\"https://www.googleapis.com/auth/classroom.guardianlinks.students\", \"View and manage guardians for students in your Google Classroom classes\", false),\n    CLASSROOM_GUARDIANLINKS_ME_READONLY(\"https://www.googleapis.com/auth/classroom.guardianlinks.me.readonly\", \"View your Google Classroom guardians\", false),\n    CLASSROOM_COURSEWORK_STUDENTS_READONLY(\"https://www.googleapis.com/auth/classroom.coursework.students.readonly\", \"View course work and grades for students in the Google Classroom classes you teach or administer\", false),\n    CLASSROOM_COURSEWORK_STUDENTS(\"https://www.googleapis.com/auth/classroom.coursework.students\", \"Manage course work and grades for students in the Google Classroom classes you teach and view the course work and grades for classes you administer\", false),\n    CLASSROOM_COURSEWORK_ME_READONLY(\"https://www.googleapis.com/auth/classroom.coursework.me.readonly\", \"View your course work and grades in Google Classroom\", false),\n    CLASSROOM_COURSEWORK_ME(\"https://www.googleapis.com/auth/classroom.coursework.me\", \"Manage your course work and view your grades in Google Classroom\", false),\n    CLASSROOM_COURSES_READONLY(\"https://www.googleapis.com/auth/classroom.courses.readonly\", \"View your Google Classroom classes\", false),\n    CLASSROOM_COURSES(\"https://www.googleapis.com/auth/classroom.courses\", \"Manage your Google Classroom classes\", false),\n    CLASSROOM_ANNOUNCEMENTS_READONLY(\"https://www.googleapis.com/auth/classroom.announcements.readonly\", \"View announcements in Google Classroom\", false),\n    CLASSROOM_ANNOUNCEMENTS(\"https://www.googleapis.com/auth/classroom.announcements\", \"View and manage announcements in Google Classroom\", false),\n    CALENDAR_SETTINGS_READONLY(\"https://www.googleapis.com/auth/calendar.settings.readonly\", \"View your Calendar settings\", false),\n    CALENDAR_READONLY(\"https://www.googleapis.com/auth/calendar.readonly\", \"View your calendars\", false),\n    CALENDAR_EVENTS_READONLY(\"https://www.googleapis.com/auth/calendar.events.readonly\", \"View events on all your calendars\", false),\n    CALENDAR_EVENTS(\"https://www.googleapis.com/auth/calendar.events\", \"View and edit events on all your calendars\", false),\n    CALENDAR(\"https://www.googleapis.com/auth/calendar\", \"See, edit, share, and permanently delete all the calendars you can access using Google Calendar\", false),\n    CALENDAR_FEEDS(\"https://www.google.com/calendar/feeds\", \"See, edit, share, and permanently delete all the calendars you can access using Google Calendar\", false),\n    BOOKS(\"https://www.googleapis.com/auth/books\", \"Manage your books\", false),\n    BLOGGER_READONLY(\"https://www.googleapis.com/auth/blogger.readonly\", \"View your Blogger account\", false),\n    BLOGGER(\"https://www.googleapis.com/auth/blogger\", \"Manage your Blogger account\", false),\n    BIGTABLE_ADMIN_TABLE(\"https://www.googleapis.com/auth/bigtable.admin.table\", \"Administer your Cloud Bigtable tables\", false),\n    BIGTABLE_ADMIN_INSTANCE(\"https://www.googleapis.com/auth/bigtable.admin.instance\", \"Administer your Cloud Bigtable clusters\", false),\n    BIGTABLE_ADMIN_CLUSTER(\"https://www.googleapis.com/auth/bigtable.admin.cluster\", \"Administer your Cloud Bigtable clusters\", false),\n    BIGTABLE_ADMIN(\"https://www.googleapis.com/auth/bigtable.admin\", \"Administer your Cloud Bigtable tables and clusters\", false),\n    BIGQUERY_READONLY(\"https://www.googleapis.com/auth/bigquery.readonly\", \"View your data in Google BigQuery\", false),\n    BIGQUERY_INSERTDATA(\"https://www.googleapis.com/auth/bigquery.insertdata\", \"Insert data into Google BigQuery\", false),\n    BIGQUERY(\"https://www.googleapis.com/auth/bigquery\", \"View and manage your data in Google BigQuery\", false),\n    APPS_ORDER_READONLY(\"https://www.googleapis.com/auth/apps.order.readonly\", \"Manage users on your domain\", false),\n    APPS_ORDER(\"https://www.googleapis.com/auth/apps.order\", \"Manage users on your domain\", false),\n    APPS_LICENSING(\"https://www.googleapis.com/auth/apps.licensing\", \"View and manage G Suite licenses for your domain\", false),\n    APPS_GROUPS_SETTINGS(\"https://www.googleapis.com/auth/apps.groups.settings\", \"View and manage the settings of a G Suite group\", false),\n    APPS_GROUPS_MIGRATION(\"https://www.googleapis.com/auth/apps.groups.migration\", \"Manage messages in groups on your domain\", false),\n    APPS_ALERTS(\"https://www.googleapis.com/auth/apps.alerts\", \"See and delete your domain's G Suite alerts, and send alert feedback\", false),\n    APPENGINE_ADMIN(\"https://www.googleapis.com/auth/appengine.admin\", \"View and manage your applications deployed on Google App Engine\", false),\n    ANDROIDPUBLISHER(\"https://www.googleapis.com/auth/androidpublisher\", \"View and manage your Google Play Developer account\", false),\n    ANDROIDMANAGEMENT(\"https://www.googleapis.com/auth/androidmanagement\", \"Manage Android devices and apps for your customers\", false),\n    ANDROIDENTERPRISE(\"https://www.googleapis.com/auth/androidenterprise\", \"Manage corporate Android devices\", false),\n    ANALYTICS_USER_DELETION(\"https://www.googleapis.com/auth/analytics.user.deletion\", \"Manage Google Analytics user deletion requests\", false),\n    ANALYTICS_READONLY(\"https://www.googleapis.com/auth/analytics.readonly\", \"View your Google Analytics data\", false),\n    ANALYTICS_PROVISION(\"https://www.googleapis.com/auth/analytics.provision\", \"Create a new Google Analytics account along with its default property and view\", false),\n    ANALYTICS_MANAGE_USERS_READONLY(\"https://www.googleapis.com/auth/analytics.manage.users.readonly\", \"View Google Analytics user permissions\", false),\n    ANALYTICS_MANAGE_USERS(\"https://www.googleapis.com/auth/analytics.manage.users\", \"Manage Google Analytics Account users by email address\", false),\n    ANALYTICS_EDIT(\"https://www.googleapis.com/auth/analytics.edit\", \"Edit Google Analytics management entities\", false),\n    ANALYTICS(\"https://www.googleapis.com/auth/analytics\", \"View and manage your Google Analytics data\", false),\n    ADSENSEHOST(\"https://www.googleapis.com/auth/adsensehost\", \"View and manage your AdSense host data and associated accounts\", false),\n    ADSENSE_READONLY(\"https://www.googleapis.com/auth/adsense.readonly\", \"View your AdSense data\", false),\n    ADSENSE(\"https://www.googleapis.com/auth/adsense\", \"View and manage your AdSense data\", false),\n    ADMIN_REPORTS_USAGE_READONLY(\"https://www.googleapis.com/auth/admin.reports.usage.readonly\", \"View usage reports for your G Suite domain\", false),\n    ADMIN_REPORTS_AUDIT_READONLY(\"https://www.googleapis.com/auth/admin.reports.audit.readonly\", \"View audit reports for your G Suite domain\", false),\n    ADMIN_DIRECTORY_USERSCHEMA_READONLY(\"https://www.googleapis.com/auth/admin.directory.userschema.readonly\", \"View user schemas on your domain\", false),\n    ADMIN_DIRECTORY_USERSCHEMA(\"https://www.googleapis.com/auth/admin.directory.userschema\", \"View and manage the provisioning of user schemas on your domain\", false),\n    ADMIN_DIRECTORY_USER_SECURITY(\"https://www.googleapis.com/auth/admin.directory.user.security\", \"Manage data access permissions for users on your domain\", false),\n    ADMIN_DIRECTORY_USER_READONLY(\"https://www.googleapis.com/auth/admin.directory.user.readonly\", \"View users on your domain\", false),\n    ADMIN_DIRECTORY_USER_ALIAS_READONLY(\"https://www.googleapis.com/auth/admin.directory.user.alias.readonly\", \"View user aliases on your domain\", false),\n    ADMIN_DIRECTORY_USER_ALIAS(\"https://www.googleapis.com/auth/admin.directory.user.alias\", \"View and manage user aliases on your domain\", false),\n    ADMIN_DIRECTORY_USER(\"https://www.googleapis.com/auth/admin.directory.user\", \"View and manage the provisioning of users on your domain\", false),\n    ADMIN_DIRECTORY_ROLEMANAGEMENT_READONLY(\"https://www.googleapis.com/auth/admin.directory.rolemanagement.readonly\", \"View delegated admin roles for your domain\", false),\n    ADMIN_DIRECTORY_ROLEMANAGEMENT(\"https://www.googleapis.com/auth/admin.directory.rolemanagement\", \"Manage delegated admin roles for your domain\", false),\n    ADMIN_DIRECTORY_RESOURCE_CALENDAR_READONLY(\"https://www.googleapis.com/auth/admin.directory.resource.calendar.readonly\", \"View calendar resources on your domain\", false),\n    ADMIN_DIRECTORY_RESOURCE_CALENDAR(\"https://www.googleapis.com/auth/admin.directory.resource.calendar\", \"View and manage the provisioning of calendar resources on your domain\", false),\n    ADMIN_DIRECTORY_ORGUNIT_READONLY(\"https://www.googleapis.com/auth/admin.directory.orgunit.readonly\", \"View organization units on your domain\", false),\n    ADMIN_DIRECTORY_ORGUNIT(\"https://www.googleapis.com/auth/admin.directory.orgunit\", \"View and manage organization units on your domain\", false),\n    ADMIN_DIRECTORY_NOTIFICATIONS(\"https://www.googleapis.com/auth/admin.directory.notifications\", \"View and manage notifications received on your domain\", false),\n    ADMIN_DIRECTORY_GROUP_READONLY(\"https://www.googleapis.com/auth/admin.directory.group.readonly\", \"View groups on your domain\", false),\n    ADMIN_DIRECTORY_GROUP_MEMBER_READONLY(\"https://www.googleapis.com/auth/admin.directory.group.member.readonly\", \"View group subscriptions on your domain\", false),\n    ADMIN_DIRECTORY_GROUP_MEMBER(\"https://www.googleapis.com/auth/admin.directory.group.member\", \"View and manage group subscriptions on your domain\", false),\n    ADMIN_DIRECTORY_GROUP(\"https://www.googleapis.com/auth/admin.directory.group\", \"View and manage the provisioning of groups on your domain\", false),\n    ADMIN_DIRECTORY_DOMAIN_READONLY(\"https://www.googleapis.com/auth/admin.directory.domain.readonly\", \"View domains related to your customers\", false),\n    ADMIN_DIRECTORY_DOMAIN(\"https://www.googleapis.com/auth/admin.directory.domain\", \"View and manage the provisioning of domains for your customers\", false),\n    ADMIN_DIRECTORY_DEVICE_MOBILE_READONLY(\"https://www.googleapis.com/auth/admin.directory.device.mobile.readonly\", \"View your mobile devices' metadata\", false),\n    ADMIN_DIRECTORY_DEVICE_MOBILE_ACTION(\"https://www.googleapis.com/auth/admin.directory.device.mobile.action\", \"Manage your mobile devices by performing administrative tasks\", false),\n    ADMIN_DIRECTORY_DEVICE_MOBILE(\"https://www.googleapis.com/auth/admin.directory.device.mobile\", \"View and manage your mobile devices' metadata\", false),\n    ADMIN_DIRECTORY_DEVICE_CHROMEOS_READONLY(\"https://www.googleapis.com/auth/admin.directory.device.chromeos.readonly\", \"View your Chrome OS devices' metadata\", false),\n    ADMIN_DIRECTORY_DEVICE_CHROMEOS(\"https://www.googleapis.com/auth/admin.directory.device.chromeos\", \"View and manage your Chrome OS devices' metadata\", false),\n    ADMIN_DIRECTORY_CUSTOMER_READONLY(\"https://www.googleapis.com/auth/admin.directory.customer.readonly\", \"View customer related information\", false),\n    ADMIN_DIRECTORY_CUSTOMER(\"https://www.googleapis.com/auth/admin.directory.customer\", \"View and manage customer related information\", false),\n    ADMIN_DATATRANSFER_READONLY(\"https://www.googleapis.com/auth/admin.datatransfer.readonly\", \"View data transfers between users in your organization\", false),\n    ADMIN_DATATRANSFER(\"https://www.googleapis.com/auth/admin.datatransfer\", \"View and manage data transfers between users in your organization\", false),\n    ADEXCHANGE_BUYER(\"https://www.googleapis.com/auth/adexchange.buyer\", \"Manage your Ad Exchange buyer account configuration\", false),\n    ;\n\n    private final String scope;\n    private final String description;\n    private final boolean isDefault;\n\n\n    public static List<String> getAdminDirectoryScopes() {\n        return Arrays.stream(new AuthGoogleScope[]{\n            ADMIN_DIRECTORY_USERSCHEMA_READONLY,\n            ADMIN_DIRECTORY_USERSCHEMA,\n            ADMIN_DIRECTORY_USER_SECURITY,\n            ADMIN_DIRECTORY_USER_READONLY,\n            ADMIN_DIRECTORY_USER_ALIAS_READONLY,\n            ADMIN_DIRECTORY_USER_ALIAS,\n            ADMIN_DIRECTORY_USER,\n            ADMIN_DIRECTORY_ROLEMANAGEMENT_READONLY,\n            ADMIN_DIRECTORY_ROLEMANAGEMENT,\n            ADMIN_DIRECTORY_RESOURCE_CALENDAR_READONLY,\n            ADMIN_DIRECTORY_RESOURCE_CALENDAR,\n            ADMIN_DIRECTORY_ORGUNIT_READONLY,\n            ADMIN_DIRECTORY_ORGUNIT,\n            ADMIN_DIRECTORY_NOTIFICATIONS,\n            ADMIN_DIRECTORY_GROUP_READONLY,\n            ADMIN_DIRECTORY_GROUP_MEMBER_READONLY,\n            ADMIN_DIRECTORY_GROUP_MEMBER,\n            ADMIN_DIRECTORY_GROUP,\n            ADMIN_DIRECTORY_DOMAIN_READONLY,\n            ADMIN_DIRECTORY_DOMAIN,\n            ADMIN_DIRECTORY_DEVICE_MOBILE_READONLY,\n            ADMIN_DIRECTORY_DEVICE_MOBILE_ACTION,\n            ADMIN_DIRECTORY_DEVICE_MOBILE,\n            ADMIN_DIRECTORY_DEVICE_CHROMEOS_READONLY,\n            ADMIN_DIRECTORY_DEVICE_CHROMEOS,\n            ADMIN_DIRECTORY_CUSTOMER_READONLY,\n            ADMIN_DIRECTORY_CUSTOMER\n        }).map(AuthGoogleScope::getScope).collect(Collectors.toList());\n    }\n\n    /**\n     * View And manage user's mail in Gmail.\n     *\n     * @return List\n     */\n    public static List<String> getGmailScopes() {\n        return Arrays.stream(new AuthGoogleScope[]{\n            GMAIL,\n            GMAIL_SETTINGS_SHARING,\n            GMAIL_SETTINGS_BASIC,\n            GMAIL_SEND,\n            GMAIL_READONLY,\n            GMAIL_MODIFY,\n            GMAIL_METADATA,\n            GMAIL_LABELS,\n            GMAIL_INSERT,\n            GMAIL_COMPOSE,\n            GMAIL_ADDONS_CURRENT_MESSAGE_READONLY,\n            GMAIL_ADDONS_CURRENT_MESSAGE_METADATA,\n            GMAIL_ADDONS_CURRENT_MESSAGE_ACTION,\n            GMAIL_ADDONS_CURRENT_ACTION_COMPOSE\n        }).map(AuthGoogleScope::getScope).collect(Collectors.toList());\n    }\n\n\n    /**\n     * Used for OIDC authorization and certification\n     *\n     * @return List\n     */\n    public static List<String> getOidcScopes() {\n        return Arrays.stream(new AuthGoogleScope[]{\n            USER_OPENID,\n            USER_EMAIL,\n            USER_PROFILE\n        }).map(AuthGoogleScope::getScope).collect(Collectors.toList());\n    }\n\n    /**\n     * View And manage user's detail and Google Contacts.\n     *\n     * @return List\n     */\n    public static List<String> getPeopleScopes() {\n        return Arrays.stream(new AuthGoogleScope[]{\n            CONTACTS_READONLY,\n            CONTACTS_OTHER_READONLY,\n            CONTACTS,\n            CONTACTS_FEEDS,\n            DIRECTORY_READONLY,\n            USER_PHONENUMBERS_READ,\n            USER_ORGANIZATION_READ,\n            USER_GENDER_READ,\n            USER_EMAILS_READ,\n            USER_BIRTHDAY_READ,\n            USER_ADDRESSES_READ,\n            USERINFO_PROFILE,\n            USERINFO_EMAIL\n        }).map(AuthGoogleScope::getScope).collect(Collectors.toList());\n    }\n\n\n    /**\n     * View and manage user's photo library.\n     *\n     * @return List\n     */\n    public static List<String> getPhotosLibraryScopes() {\n        return Arrays.stream(new AuthGoogleScope[]{\n            PHOTOSLIBRARY_SHARING,\n            PHOTOSLIBRARY_READONLY_APPCREATEDDATA,\n            PHOTOSLIBRARY_READONLY,\n            PHOTOSLIBRARY_APPENDONLY,\n            PHOTOSLIBRARY\n        }).map(AuthGoogleScope::getScope).collect(Collectors.toList());\n    }\n\n    /**\n     * View And manage user's videos, activity and playlists.\n     *\n     * @return List\n     */\n    public static List<String> getYouTubeScopes() {\n        return Arrays.stream(new AuthGoogleScope[]{\n            YT_ANALYTICS_READONLY,\n            YT_ANALYTICS_MONETARY_READONLY,\n            YOUTUBEPARTNER_CHANNEL_AUDIT,\n            YOUTUBEPARTNER,\n            YOUTUBE_UPLOAD,\n            YOUTUBE_READONLY,\n            YOUTUBE_FORCE_SSL,\n            YOUTUBE_CHANNEL_MEMBERSHIPS_CREATOR,\n            YOUTUBE\n        }).map(AuthGoogleScope::getScope).collect(Collectors.toList());\n    }\n\n    /**\n     * View And manage user's Google Analytics.\n     *\n     * @return List\n     */\n    public static List<String> getGoogleAnalyticsScopes() {\n        return Arrays.stream(new AuthGoogleScope[]{\n            ANALYTICS_USER_DELETION,\n            ANALYTICS_READONLY,\n            ANALYTICS_PROVISION,\n            ANALYTICS_MANAGE_USERS_READONLY,\n            ANALYTICS_MANAGE_USERS,\n            ANALYTICS_EDIT,\n            ANALYTICS\n        }).map(AuthGoogleScope::getScope).collect(Collectors.toList());\n    }\n\n    /**\n     * View And manage user's calendars in Google Calendar.\n     *\n     * @return List\n     */\n    public static List<String> getCalendarScopes() {\n        return Arrays.stream(new AuthGoogleScope[]{\n            CALENDAR_SETTINGS_READONLY,\n            CALENDAR_READONLY,\n            CALENDAR_EVENTS_READONLY,\n            CALENDAR_EVENTS,\n            CALENDAR,\n            CALENDAR_FEEDS\n        }).map(AuthGoogleScope::getScope).collect(Collectors.toList());\n    }\n\n    /**\n     * List, download, create, move, edit, share and search all of user's documents and files in Google Drive.\n     *\n     * @return List\n     */\n    public static List<String> getDriveScopes() {\n        return Arrays.stream(new AuthGoogleScope[]{\n            DRIVE_SCRIPTS,\n            DRIVE_READONLY,\n            DRIVE_PHOTOS_READONLY,\n            DRIVE_METADATA_READONLY,\n            DRIVE_METADATA,\n            DRIVE_FILE,\n            DRIVE_APPDATA,\n            DRIVE_ACTIVITY_READONLY,\n            DRIVE_ACTIVITY,\n            DRIVE,\n            ACTIVITY\n        }).map(AuthGoogleScope::getScope).collect(Collectors.toList());\n    }\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/enums/scope/AuthHuaweiScope.java",
    "content": "package me.zhyd.oauth.enums.scope;\n\nimport lombok.AllArgsConstructor;\nimport lombok.Getter;\n\n/**\n * 华为平台 OAuth 授权范围\n *\n * 当前方式未来可能被废弃，建议使用 {@link AuthHuaweiV3Scope}\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @version 1.0.0\n * @since 1.0.0\n */\n@Getter\n@AllArgsConstructor\n@Deprecated\npublic enum AuthHuaweiScope implements AuthScope {\n\n    /**\n     * {@code scope} 含义，以{@code description} 为准\n     */\n    BASE_PROFILE(\"https://www.huawei.com/auth/account/base.profile\", \"获取用户的基本信息\", true),\n    MOBILE_NUMBER(\"https://www.huawei.com/auth/account/mobile.number\", \"获取用户的手机号\", false),\n    ACCOUNTLIST(\"https://www.huawei.com/auth/account/accountlist\", \"获取用户的账单列表\", false),\n\n    /**\n     * 以下两个 scope 不需要经过华为评估和验证\n     */\n    SCOPE_DRIVE_FILE(\"https://www.huawei.com/auth/drive.file\", \"只允许访问由应用程序创建或打开的文件\", false),\n    SCOPE_DRIVE_APPDATA(\"https://www.huawei.com/auth/drive.appdata\", \"只允许访问由应用程序创建或打开的文件\", false),\n    /**\n     * 以下四个 scope 使用前需要向drivekit@huawei.com提交申请\n     * <p>\n     * 参考：https://developer.huawei.com/consumer/cn/doc/development/HMSCore-Guides-V5/server-dev-0000001050039664-V5#ZH-CN_TOPIC_0000001050039664__section1618418855716\n     */\n    SCOPE_DRIVE(\"https://www.huawei.com/auth/drive\", \"只允许访问由应用程序创建或打开的文件\", false),\n    SCOPE_DRIVE_READONLY(\"https://www.huawei.com/auth/drive.readonly\", \"只允许访问由应用程序创建或打开的文件\", false),\n    SCOPE_DRIVE_METADATA(\"https://www.huawei.com/auth/drive.metadata\", \"只允许访问由应用程序创建或打开的文件\", false),\n    SCOPE_DRIVE_METADATA_READONLY(\"https://www.huawei.com/auth/drive.metadata.readonly\", \"只允许访问由应用程序创建或打开的文件\", false),\n\n\n    ;\n\n    private final String scope;\n    private final String description;\n    private final boolean isDefault;\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/enums/scope/AuthHuaweiV3Scope.java",
    "content": "package me.zhyd.oauth.enums.scope;\n\nimport lombok.AllArgsConstructor;\nimport lombok.Getter;\n\n/**\n * 华为平台 V3 版本 OAuth 授权范围\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @version 1.0.0\n * @since 1.16.7\n */\n@Getter\n@AllArgsConstructor\npublic enum AuthHuaweiV3Scope implements AuthScope {\n\n    /**\n     * {@code scope} 含义，以{@code description} 为准\n     */\n    OPENID(\"openid\", \"基础scope，v3必选\", true),\n    /**\n     * {@code scope} 含义，以{@code description} 为准\n     */\n    BASE_PROFILE(\"https://www.huawei.com/auth/account/base.profile\", \"获取用户的基本信息\", true),\n    MOBILE_NUMBER(\"https://www.huawei.com/auth/account/mobile.number\", \"获取用户的手机号\", false),\n    ACCOUNTLIST(\"https://www.huawei.com/auth/account/accountlist\", \"获取用户的账单列表\", false),\n\n    /**\n     * 以下两个 scope 不需要经过华为评估和验证\n     */\n    SCOPE_DRIVE_FILE(\"https://www.huawei.com/auth/drive.file\", \"只允许访问由应用程序创建或打开的文件\", false),\n    SCOPE_DRIVE_APPDATA(\"https://www.huawei.com/auth/drive.appdata\", \"只允许访问由应用程序创建或打开的文件\", false),\n    /**\n     * 以下四个 scope 使用前需要向drivekit@huawei.com提交申请\n     * <p>\n     * 参考：https://developer.huawei.com/consumer/cn/doc/development/HMSCore-Guides-V5/server-dev-0000001050039664-V5#ZH-CN_TOPIC_0000001050039664__section1618418855716\n     */\n    SCOPE_DRIVE(\"https://www.huawei.com/auth/drive\", \"只允许访问由应用程序创建或打开的文件\", false),\n    SCOPE_DRIVE_READONLY(\"https://www.huawei.com/auth/drive.readonly\", \"只允许访问由应用程序创建或打开的文件\", false),\n    SCOPE_DRIVE_METADATA(\"https://www.huawei.com/auth/drive.metadata\", \"只允许访问由应用程序创建或打开的文件\", false),\n    SCOPE_DRIVE_METADATA_READONLY(\"https://www.huawei.com/auth/drive.metadata.readonly\", \"只允许访问由应用程序创建或打开的文件\", false),\n\n\n    ;\n    ;\n\n    private final String scope;\n    private final String description;\n    private final boolean isDefault;\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/enums/scope/AuthJdScope.java",
    "content": "package me.zhyd.oauth.enums.scope;\n\nimport lombok.AllArgsConstructor;\nimport lombok.Getter;\n\n/**\n * 京东平台 OAuth 授权范围\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @version 1.0.0\n * @since 1.0.0\n */\n@Getter\n@AllArgsConstructor\npublic enum AuthJdScope implements AuthScope {\n\n    /**\n     * {@code scope} 含义，以{@code description} 为准\n     */\n    SNSAPI_BASE(\"snsapi_base\", \"基础授权\", true);\n\n    private final String scope;\n    private final String description;\n    private final boolean isDefault;\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/enums/scope/AuthKujialeScope.java",
    "content": "package me.zhyd.oauth.enums.scope;\n\nimport lombok.AllArgsConstructor;\nimport lombok.Getter;\n\n/**\n * 酷家乐平台 OAuth 授权范围\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @version 1.0.0\n * @since 1.0.0\n */\n@Getter\n@AllArgsConstructor\npublic enum AuthKujialeScope implements AuthScope {\n\n    /**\n     * {@code scope} 含义，以{@code description} 为准\n     */\n    GET_USER_INFO(\"get_user_info\", \"获取用户的基本信息\", true),\n    GET_DESIGN(\"get_design\", \"获取指定方案详情\", false),\n    GET_BUDGET_LIST(\"get_budget_list\", \"获取清单预算概览数据\", false);\n\n    private final String scope;\n    private final String description;\n    private final boolean isDefault;\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/enums/scope/AuthLineScope.java",
    "content": "package me.zhyd.oauth.enums.scope;\n\nimport lombok.AllArgsConstructor;\nimport lombok.Getter;\n\n/**\n * Line 平台 OAuth 授权范围\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.16.0\n */\n@Getter\n@AllArgsConstructor\npublic enum AuthLineScope implements AuthScope {\n\n    /**\n     * {@code scope} 含义，以{@code description} 为准\n     */\n\n    PROFILE(\"profile\", \"Get profile details\", true),\n    OPENID(\"openid\", \"Get id token\", true),\n    EMAIL(\"email\", \"Get email (separate authorization required)\", false);\n\n    private final String scope;\n    private final String description;\n    private final boolean isDefault;\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/enums/scope/AuthLinkedinScope.java",
    "content": "package me.zhyd.oauth.enums.scope;\n\nimport lombok.AllArgsConstructor;\nimport lombok.Getter;\n\n/**\n * 领英平台 OAuth 授权范围\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @version 1.0.0\n * @since 1.0.0\n */\n@Getter\n@AllArgsConstructor\npublic enum AuthLinkedinScope implements AuthScope {\n\n    /**\n     * {@code scope} 含义，以{@code description} 为准\n     */\n    R_LITEPROFILE(\"r_liteprofile\", \"Use your name, headline, and photo\", true),\n    R_EMAILADDRESS(\"r_emailaddress\", \"Use the primary email address associated with your LinkedIn account\", true),\n    W_MEMBER_SOCIAL(\"w_member_social\", \"Post, comment and like posts on your behalf\", true),\n    R_MEMBER_SOCIAL(\"r_member_social\", \"Retrieve your posts, comments, likes, and other engagement data\", false),\n    R_AD_CAMPAIGNS(\"r_ad_campaigns\", \"View advertising campaigns you manage\", false),\n    R_ADS(\"r_ads\", \"Retrieve your advertising accounts\", false),\n    R_ADS_LEADGEN_AUTOMATION(\"r_ads_leadgen_automation\", \"Access your Lead Gen Forms and retrieve leads\", false),\n    R_ADS_REPORTING(\"r_ads_reporting\", \"Retrieve reporting for your advertising accounts\", false),\n    R_BASICPROFILE(\"r_basicprofile\", \"Use your basic profile including your name, photo, headline, and current positions\", false),\n    R_ORGANIZATION_SOCIAL(\"r_organization_social\", \"Retrieve your organizations' posts, including any comments, likes and other engagement data\", false),\n    RW_AD_CAMPAIGNS(\"rw_ad_campaigns\", \"Manage your advertising campaigns\", false),\n    RW_ADS(\"rw_ads\", \"Manage your advertising accounts\", false),\n    RW_COMPANY_ADMIN(\"rw_company_admin\", \"For V1 callsManage your organization's page and post updates\", false),\n    RW_DMP_SEGMENTS(\"rw_dmp_segments\", \"Create and manage your matched audiences\", false),\n    RW_ORGANIZATION_ADMIN(\"rw_organization_admin\", \"Manage your organizations' pages and retrieve reporting data\", false),\n    RW_ORGANIZATION(\"rw_organization\", \"For V2 callsManage your organization's page and post updates\", false),\n    W_ORGANIZATION_SOCIAL(\"w_organization_social\", \"Post, comment and like posts on your organization's behalf\", false),\n    W_SHARE(\"w_share\", \"Post updates to LinkedIn as you\", false);\n\n    private final String scope;\n    private final String description;\n    private final boolean isDefault;\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/enums/scope/AuthMiScope.java",
    "content": "package me.zhyd.oauth.enums.scope;\n\nimport lombok.AllArgsConstructor;\nimport lombok.Getter;\n\n/**\n * 小米平台 OAuth 授权范围\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @version 1.0.0\n * @since 1.0.0\n */\n@Getter\n@AllArgsConstructor\npublic enum AuthMiScope implements AuthScope {\n\n    /**\n     * {@code scope} 含义，以{@code description} 为准\n     */\n    profile(\"user/profile\", \"获取用户的基本信息\", true),\n    OPENID(\"user/openIdV2\", \"获取用户的OpenID\", true),\n    PHONE_EMAIL(\"user/phoneAndEmail\", \"获取用户的手机号和邮箱\", true);\n\n    private final String scope;\n    private final String description;\n    private final boolean isDefault;\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/enums/scope/AuthMicrosoftScope.java",
    "content": "package me.zhyd.oauth.enums.scope;\n\nimport lombok.AllArgsConstructor;\nimport lombok.Getter;\n\n/**\n * 微软平台 OAuth 授权范围\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @version 1.0.0\n * @since 1.0.0\n */\n@Getter\n@AllArgsConstructor\npublic enum AuthMicrosoftScope implements AuthScope {\n\n    /**\n     * {@code scope} 含义，以{@code description} 为准\n     */\n    PROFILE(\"profile\", \"允许应用查看用户的基本个人资料（名称、图片、用户名称）\", true),\n    EMAIL(\"email\", \"允许应用读取用户的主电子邮件地址\", true),\n    OPENID(\"openid\", \"允许用户以其工作或学校帐户登录应用，并允许应用查看用户的基本个人资料信息\", true),\n    OFFLINE_ACCESS(\"offline_access\", \"允许应用读取和更新用户数据，即使用户当前没有在使用此应用，也不例外\", true),\n\n    USER_READ(\"User.Read\", \"登录并读取用户个人资料\", false),\n    USER_READWRITE(\"User.ReadWrite\", \"对用户个人资料的读写权限\", false),\n    USER_READBASIC_ALL(\"User.ReadBasic.All\", \"读取所有用户的基本个人资料\", false),\n    USER_READ_ALL(\"User.Read.All\", \"读取所有用户的完整个人资料\", false),\n    USER_READWRITE_ALL(\"User.ReadWrite.All\", \"读取和写入所有用户的完整个人资料\", false),\n    USER_INVITE_ALL(\"User.Invite.All\", \"将来宾用户邀请到组织\", false),\n    USER_EXPORT_ALL(\"User.Export.All\", \"导出用户数据\", false),\n    USER_MANAGEIDENTITIES_ALL(\"User.ManageIdentities.All\", \"管理所有用户标识\", false),\n\n    USERACTIVITY_READWRITE_CREATEDBYAPP(\"UserActivity.ReadWrite.CreatedByApp\", \"将应用活动读取和写入到用户的活动源\", false),\n\n    FILES_READ(\"Files.Read\", \"允许应用读取登录用户的文件\", false),\n    FILES_READ_ALL(\"Files.Read.All\", \"允许应用读取登录用户可以访问的所有文件\", false),\n    FILES_READWRITE(\"Files.ReadWrite\", \"允许应用读取、创建、更新和删除登录用户的文件\", false),\n    FILES_READWRITE_ALL(\"Files.ReadWrite.All\", \"允许应用读取、创建、更新和删除登录用户可以访问的所有文件\", false),\n    FILES_READWRITE_APPFOLDER(\"Files.ReadWrite.AppFolder\", \"允许应用读取、创建、更新和删除应用程序文件夹中的文件\", false),\n    FILES_READ_SELECTED(\"Files.Read.Selected\", \"允许应用读取用户选择的文件。在用户选择文件后，应用有几个小时的访问权限\", false),\n    FILES_READWRITE_SELECTED(\"Files.ReadWrite.Selected\", \"允许应用读取和写入用户选择的文件。在用户选择文件后，应用有几个小时的访问权限\", false),\n\n    ORGCONTACT_READ_ALL(\"OrgContact.Read.All\", \"允许应用代表已登录用户读取所有组织联系人。 这些联系人由组织管理，不同于用户的个人联系人\", false),\n\n    MAIL_READ(\"Mail.Read\", \"允许应用读取用户邮箱中的电子邮件\", false),\n    MAIL_READBASIC(\"Mail.ReadBasic\", \"允许应用读取已登录用户的邮箱，但不读取 body、bodyPreview、uniqueBody、attachments、extensions 和任何扩展属性。 不包含邮件搜索权限\", false),\n    MAIL_READWRITE(\"Mail.ReadWrite\", \"允许应用创建、读取、更新和删除用户邮箱中的电子邮件。不包括发送电子邮件的权限\", false),\n    MAIL_READ_SHARED(\"Mail.Read.Shared\", \"允许应用读取用户可以访问的邮件，包括用户个人邮件和共享邮件\", false),\n    MAIL_READWRITE_SHARED(\"Mail.ReadWrite.Shared\", \"允许应用创建、读取、更新和删除用户有权访问的邮件，包括用户个人邮件和共享邮件。不包括邮件发送权限\", false),\n    MAIL_SEND(\"Mail.Send\", \"允许应用以组织用户身份发送邮件\", false),\n    MAIL_SEND_SHARED(\"Mail.Send.Shared\", \"允许应用以登录用户身份发送邮件，包括代表他人发送邮件\", false),\n    MAILBOXSETTINGS_READ(\"MailboxSettings.Read\", \"允许应用读取用户的邮箱设置。不包括邮件发送权限\", false),\n    MAILBOXSETTINGS_READWRITE(\"MailboxSettings.ReadWrite\", \"允许应用创建、读取、更新和删除用户邮箱设置。 不包含直接发送邮件的权限，但允许应用创建能够转发或重定向邮件的规则\", false),\n\n    NOTES_READ(\"Notes.Read\", \"允许应用代表已登录用户读取 OneNote 笔记本和分区标题并创建新的页面、笔记本和分区\", false),\n    NOTES_CREATE(\"Notes.Create\", \"允许应用代创建用户 OneNote 笔记本\", false),\n    NOTES_READWRITE(\"Notes.ReadWrite\", \"允许应用代表已登录用户读取、共享和修改 OneNote 笔记本\", false),\n    NOTES_READ_ALL(\"Notes.Read.All\", \"允许应用读取登录用户在组织中有权访问的 OneNote 笔记本\", false),\n    NOTES_READWRITE_ALL(\"Notes.ReadWrite.All\", \"允许应用读取、共享和修改已登录用户在组织中有权访问的 OneNote 笔记本\", false),\n    ;\n\n    private final String scope;\n    private final String description;\n    private final boolean isDefault;\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/enums/scope/AuthOktaScope.java",
    "content": "package me.zhyd.oauth.enums.scope;\n\nimport lombok.AllArgsConstructor;\nimport lombok.Getter;\n\n/**\n * Okta 平台 OAuth 授权范围\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.16.0\n */\n@Getter\n@AllArgsConstructor\npublic enum AuthOktaScope implements AuthScope {\n\n    /**\n     * {@code scope} 含义，以{@code description} 为准\n     */\n    OPENID(\"openid\", \"Signals that a request is an OpenID request.\", true),\n    PROFILE(\"profile\", \"The exact data varies based on what profile information you have provided, such as: name, time zone, picture, or birthday.\", true),\n    EMAIL(\"email\", \"This allows the app to view your email address.\", true),\n    ADDRESS(\"address\", \"This allows the app to view your address, such as: street address, city, state, and zip code.\", true),\n    PHONE(\"phone\", \"This allows the app to view your phone number.\", true),\n    OFFLINE_ACCESS(\"offline_access\", \"This keeps you signed in to the app, even when you are not using it.\", true),\n    OKTA_USERS_MANAGE(\"okta.users.manage\", \"Allows the app to create and manage users and read all profile and credential information for users\", false),\n    OKTA_USERS_READ(\"okta.users.read\", \"Allows the app to read any user's profile and credential information\", false),\n    OKTA_USERS_MANAGE_SELF(\"okta.users.manage.self\", \"Allows the app to manage the currently signed-in user's profile. Currently only supports user profile attribute updates.\", false),\n    OKTA_USERS_READ_SELF(\"okta.users.read.self\", \"Allows the app to read the currently signed-in user's profile and credential information\", false),\n    OKTA_APPS_MANAGE(\"okta.apps.manage\", \"Allows the app to create and manage Apps in your Okta organization\", false),\n    OKTA_APPS_READ(\"okta.apps.read\", \"Allows the app to read information about Apps in your Okta organization\", false),\n    OKTA_AUTHORIZATIONSERVERS_MANAGE(\"okta.authorizationServers.manage\", \"Allows the app to manage authorization servers\", false),\n    OKTA_AUTHORIZATIONSERVERS_READ(\"okta.authorizationServers.read\", \"Allows the app to read authorization server information\", false),\n    OKTA_CLIENTS_MANAGE(\"okta.clients.manage\", \"Allows the app to manage all OAuth/OIDC clients and to create new clients\", false),\n    OKTA_CLIENTS_READ(\"okta.clients.read\", \"Allows the app to read information for all OAuth/OIDC clients\", false),\n    OKTA_CLIENTS_REGISTER(\"okta.clients.register\", \"Allows the app to register (create) new OAuth/OIDC clients (but not read information about existing clients)\", false),\n    OKTA_EVENTHOOKS_MANAGE(\"okta.eventHooks.manage\", \"Allows the app to create and manage Event Hooks in your Okta organization\", false),\n    OKTA_EVENTHOOKS_READ(\"okta.eventHooks.read\", \"Allows the app to read information about Event Hooks in your Okta organization\", false),\n    OKTA_FACTORS_MANAGE(\"okta.factors.manage\", \"Allows the app to manage all admin operations for org factors (for example, activate, deactive, read)\", false),\n    OKTA_FACTORS_READ(\"okta.factors.read\", \"Allows the app to read org factors information\", false),\n    OKTA_GROUPS_MANAGE(\"okta.groups.manage\", \"Allows the app to manage groups in your Okta organization\", false),\n    OKTA_GROUPS_READ(\"okta.groups.read\", \"Allows the app to read information about groups and their members in your Okta organization\", false),\n    OKTA_IDPS_MANAGE(\"okta.idps.manage\", \"Allows the app to create and manage Identity Providers in your Okta organization\", false),\n    OKTA_IDPS_READ(\"okta.idps.read\", \"Allows the app to read information about Identity Providers in your Okta organization\", false),\n    OKTA_INLINEHOOKS_MANAGE(\"okta.inlineHooks.manage\", \"Allows the app to create and manage Inline Hooks in your Okta organization.\", false),\n    OKTA_INLINEHOOKS_READ(\"okta.inlineHooks.read\", \"Allows the app to read information about Inline Hooks in your Okta organization.\", false),\n    OKTA_LINKEDOBJECTS_MANAGE(\"okta.linkedObjects.manage\", \"Allows the app to manage Linked Object definitions in your Okta organization.\", false),\n    OKTA_LINKEDOBJECTS_READ(\"okta.linkedObjects.read\", \"Allows the app to read Linked Object definitions in your Okta organization.\", false),\n    OKTA_LOGS_READ(\"okta.logs.read\", \"Allows the app to read information about System Log entries in your Okta organization\", false),\n    OKTA_ROLES_MANAGE(\"okta.roles.manage\", \"Allows the app to create and manage Administrator Roles in your Okta organization\", false),\n    OKTA_ROLES_READ(\"okta.roles.read\", \"Allows the app to read information about Administrator Roles in your Okta organization\", false),\n    OKTA_SCHEMAS_MANAGE(\"okta.schemas.manage\", \"Allows the app to create and manage Schemas in your Okta organization\", false),\n    OKTA_SCHEMAS_READ(\"okta.schemas.read\", \"Allows the app to read information about Schemas in your Okta organization\", false),\n    OKTA_SESSIONS_MANAGE(\"okta.sessions.manage\", \"Allows the app to manage all sessions in your Okta organization\", false),\n    OKTA_SESSIONS_READ(\"okta.sessions.read\", \"Allows the app to read all sessions in your Okta organization\", false),\n    OKTA_TEMPLATES_MANAGE(\"okta.templates.manage\", \"Allows the app to manage all custom templates in your Okta organization\", false),\n    OKTA_TEMPLATES_READ(\"okta.templates.read\", \"Allows the app to read all custom templates in your Okta organization\", false),\n    OKTA_TRUSTEDORIGINS_MANAGE(\"okta.trustedOrigins.manage\", \"Allows the app to manage all Trusted Origins in your Okta organization\", false),\n    OKTA_TRUSTEDORIGINS_READ(\"okta.trustedOrigins.read\", \"Allows the app to read all Trusted Origins in your Okta organization\", false),\n    OKTA_POLICIES_MANAGE(\"okta.policies.manage\", \"Allows the app to manage Policies in your Okta organization\", false),\n    OKTA_POLICIES_READ(\"okta.policies.read\", \"Allows the app to read information about Policies in your Okta organization\", false),;\n\n    private final String scope;\n    private final String description;\n    private final boolean isDefault;\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/enums/scope/AuthPinterestScope.java",
    "content": "package me.zhyd.oauth.enums.scope;\n\nimport lombok.AllArgsConstructor;\nimport lombok.Getter;\n\n/**\n * Pinterest 平台 OAuth 授权范围\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @version 1.0.0\n * @since 1.0.0\n */\n@Getter\n@AllArgsConstructor\npublic enum AuthPinterestScope implements AuthScope {\n\n    /**\n     * {@code scope} 含义，以{@code description} 为准\n     */\n    READ_PUBLIC(\"read_public\", \"Use GET method on a user’s Pins, boards.\", true),\n    WRITE_PUBLIC(\"write_public\", \"Use PATCH, POST and DELETE methods on a user’s Pins and boards.\", false),\n    READ_RELATIONSHIPS(\"read_relationships\", \"Use GET method on a user’s follows and followers (on boards, users and interests).\", false),\n    WRITE_RELATIONSHIPS(\"write_relationships\", \"Use PATCH, POST and DELETE methods on a user’s follows and followers (on boards, users and interests).\", false),\n    ;\n\n    private final String scope;\n    private final String description;\n    private final boolean isDefault;\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/enums/scope/AuthProginnScope.java",
    "content": "package me.zhyd.oauth.enums.scope;\n\nimport lombok.AllArgsConstructor;\nimport lombok.Getter;\n\n/**\n * Gitee 平台 OAuth 授权范围\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @version 1.0.0\n * @since 1.0.0\n */\n@Getter\n@AllArgsConstructor\npublic enum AuthProginnScope implements AuthScope {\n\n    /**\n     * {@code scope} 含义，以{@code description} 为准\n     */\n    BASIC(\"basic\", \"访问用户的基本信息\", true),\n    /**\n     * 以上 scope 需要单独向程序员客栈平台申请，否则不可使用\n     */\n    email(\"email\", \"获取用户的邮箱\", false),\n    realname(\"realname\", \"获取用户的真实姓名\", false),\n    cellphone(\"cellphone\", \"获取用户的手机号码\", false),\n   ;\n\n    private final String scope;\n    private final String description;\n    private final boolean isDefault;\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/enums/scope/AuthQqScope.java",
    "content": "package me.zhyd.oauth.enums.scope;\n\nimport lombok.AllArgsConstructor;\nimport lombok.Getter;\n\n/**\n * QQ 平台 OAuth 授权范围\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @version 1.0.0\n * @since 1.0.0\n */\n@Getter\n@AllArgsConstructor\npublic enum AuthQqScope implements AuthScope {\n\n    /**\n     * {@code scope} 含义，以{@code description} 为准\n     */\n    GET_USER_INFO(\"get_user_info\", \"获取登录用户的昵称、头像、性别\", true),\n    /**\n     * 以下 scope 需要申请：http://wiki.connect.qq.com/openapi%e6%9d%83%e9%99%90%e7%94%b3%e8%af%b7\n     */\n    GET_VIP_INFO(\"get_vip_info\", \"获取QQ会员的基本信息\", false),\n    GET_VIP_RICH_INFO(\"get_vip_rich_info\", \"获取QQ会员的高级信息\", false),\n    LIST_ALBUM(\"list_album\", \"获取用户QQ空间相册列表\", false),\n    UPLOAD_PIC(\"upload_pic\", \"上传一张照片到QQ空间相册\", false),\n    ADD_ALBUM(\"add_album\", \"在用户的空间相册里，创建一个新的个人相册\", false),\n    LIST_PHOTO(\"list_photo\", \"获取用户QQ空间相册中的照片列表\", false);\n\n    private final String scope;\n    private final String description;\n    private final boolean isDefault;\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/enums/scope/AuthRenrenScope.java",
    "content": "package me.zhyd.oauth.enums.scope;\n\nimport lombok.AllArgsConstructor;\nimport lombok.Getter;\n\n/**\n * 人人平台 OAuth 授权范围\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @version 1.0.0\n * @since 1.0.0\n */\n@Getter\n@AllArgsConstructor\npublic enum AuthRenrenScope implements AuthScope {\n\n    /**\n     * {@code scope} 含义，以{@code description} 为准\n     */\n    READ_USER_BLOG(\"read_user_blog\", \"获取用户日志时需要用户授予的权限。\", false),\n    READ_USER_CHECKIN(\"read_user_checkin\", \"获取用户报到信息时需要用户授予的权限。\", false),\n    READ_USER_FEED(\"read_user_feed\", \"获取用户新鲜事时需要用户授予的权限。\", false),\n    READ_USER_GUESTBOOK(\"read_user_guestbook\", \"获取用户留言板时需要用户授予的权限。\", false),\n    READ_USER_INVITATION(\"read_user_invitation\", \"获取用户被邀请的状况时需要用户授予的权限。\", false),\n    READ_USER_LIKE_HISTORY(\"read_user_like_history\", \"获取用户喜欢的历史信息时需要用户授予的权限。\", false),\n    READ_USER_MESSAGE(\"read_user_message\", \"获取用户站内信时需要用户授予的权限。\", false),\n    READ_USER_NOTIFICATION(\"read_user_notification\", \"获取用户已收到的通知时需要用户授予的权限。\", false),\n    READ_USER_PHOTO(\"read_user_photo\", \"获取用户相册相关信息时需要用户授予的权限。\", false),\n    READ_USER_STATUS(\"read_user_status\", \"获取用户状态相关信息时需要用户授予的权限。\", false),\n    READ_USER_ALBUM(\"read_user_album\", \"获取用户相册相关信息时需要用户授予的权限。\", false),\n    READ_USER_COMMENT(\"read_user_comment\", \"获取用户评论相关信息时需要用户授予的权限。\", false),\n    READ_USER_SHARE(\"read_user_share\", \"获取用户分享相关信息时需要用户授予的权限。\", false),\n    READ_USER_REQUEST(\"read_user_request\", \"获取用户好友请求、圈人请求等信息时需要用户授予的权限。\", false),\n    PUBLISH_BLOG(\"publish_blog\", \"以用户身份发布日志时需要用户授予的权限。\", false),\n    PUBLISH_CHECKIN(\"publish_checkin\", \"以用户身份发布报到时需要用户授予的权限。\", false),\n    PUBLISH_FEED(\"publish_feed\", \"以用户身份发送新鲜事时需要用户授予的权限。\", false),\n    PUBLISH_SHARE(\"publish_share\", \"以用户身份发送分享时需要用户授予的权限。\", false),\n    WRITE_GUESTBOOK(\"write_guestbook\", \"以用户身份进行留言时需要用户授予的权限。\", false),\n    SEND_INVITATION(\"send_invitation\", \"以用户身份发送邀请时需要用户授予的权限。\", false),\n    SEND_REQUEST(\"send_request\", \"以用户身份发送好友申请、圈人请求等时需要用户授予的权限。\", false),\n    SEND_MESSAGE(\"send_message\", \"以用户身份发送站内信时需要用户授予的权限。\", false),\n    SEND_NOTIFICATION(\"send_notification\", \"以用户身份发送通知（user_to_user）时需要用户授予的权限。\", false),\n    PHOTO_UPLOAD(\"photo_upload\", \"以用户身份上传照片时需要用户授予的权限。\", false),\n    STATUS_UPDATE(\"status_update\", \"以用户身份发布状态时需要用户授予的权限。\", false),\n    CREATE_ALBUM(\"create_album\", \"以用户身份发布相册时需要用户授予的权限。\", false),\n    PUBLISH_COMMENT(\"publish_comment\", \"以用户身份发布评论时需要用户授予的权限。\", false),\n    OPERATE_LIKE(\"operate_like\", \"以用户身份执行喜欢操作时需要用户授予的权限。\", false),\n    ADMIN_PAGE(\"admin_page\", \"以用户的身份，管理其可以管理的公共主页的权限。\", false),\n    ;\n\n    private final String scope;\n    private final String description;\n    private final boolean isDefault;\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/enums/scope/AuthScope.java",
    "content": "package me.zhyd.oauth.enums.scope;\n\n/**\n * 各个平台 scope 类的统一接口\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @version 1.0.0\n * @since 1.15.7\n */\npublic interface AuthScope {\n\n    /**\n     * 获取字符串 {@code scope}，对应为各平台实际使用的 {@code scope}\n     *\n     * @return String\n     */\n    String getScope();\n\n    /**\n     * 判断当前 {@code scope} 是否为各平台默认启用的\n     *\n     * @return boolean\n     */\n    boolean isDefault();\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/enums/scope/AuthSlackScope.java",
    "content": "package me.zhyd.oauth.enums.scope;\n\nimport lombok.AllArgsConstructor;\nimport lombok.Getter;\n\n/**\n * Slack 平台 OAuth 授权范围\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.16.0\n */\n@Getter\n@AllArgsConstructor\npublic enum AuthSlackScope implements AuthScope {\n\n    /**\n     * {@code scope} 含义，以{@code description} 为准\n     */\n    USERS_PROFILE_READ(\"users.profile:read\", \"View profile details about people in a workspace\", true),\n    USERS_READ(\"users:read\", \"View people in a workspace\", true),\n    USERS_READ_EMAIL(\"users:read.email\", \"View email addresses of people in a workspace\", true),\n    USERS_PROFILE_WRITE(\"users.profile:write\", \"Edit a user’s profile information and status\", false),\n    USERS_PROFILE_WRITE_USER(\"users.profile:write:user\", \"Change the user's profile fields\", false),\n    USERS_WRITE(\"users:write\", \"Set presence for your slack app\", false),\n    ADMIN(\"admin\", \"Administer a workspace\", false),\n    ADMIN_ANALYTICS_READ(\"admin.analytics:read\", \"Access analytics data about the organization\", false),\n    ADMIN_APPS_READ(\"admin.apps:read\", \"View apps and app requests in a workspace\", false),\n    ADMIN_APPS_WRITE(\"admin.apps:write\", \"Manage apps in a workspace\", false),\n    ADMIN_BARRIERS_READ(\"admin.barriers:read\", \"Read information barriers in the organization\", false),\n    ADMIN_BARRIERS_WRITE(\"admin.barriers:write\", \"Manage information barriers in the organization\", false),\n    ADMIN_CONVERSATIONS_READ(\"admin.conversations:read\", \"View the channel’s member list, topic, purpose and channel name\", false),\n    ADMIN_CONVERSATIONS_WRITE(\"admin.conversations:write\", \"Start a new conversation, modify a conversation and modify channel details\", false),\n    ADMIN_INVITES_READ(\"admin.invites:read\", \"Gain information about invite requests in a Grid organization.\", false),\n    ADMIN_INVITES_WRITE(\"admin.invites:write\", \"Approve or deny invite requests in a Grid organization.\", false),\n    ADMIN_TEAMS_READ(\"admin.teams:read\", \"Access information about a workspace\", false),\n    ADMIN_TEAMS_WRITE(\"admin.teams:write\", \"Make changes to a workspace\", false),\n    ADMIN_USERGROUPS_READ(\"admin.usergroups:read\", \"Access information about user groups\", false),\n    ADMIN_USERGROUPS_WRITE(\"admin.usergroups:write\", \"Make changes to your usergroups\", false),\n    ADMIN_USERS_READ(\"admin.users:read\", \"Access a workspace’s profile information\", false),\n    ADMIN_USERS_WRITE(\"admin.users:write\", \"Modify account information\", false),\n    APP_MENTIONS_READ(\"app_mentions:read\", \"View messages that directly mention @your_slack_app in conversations that the app is in\", false),\n    AUDITLOGS_READ(\"auditlogs:read\", \"View events from all workspaces, channels and users (Enterprise Grid only)\", false),\n    BOT(\"bot\", \"Add the ability for people to direct message or mention @your_slack_app\", false),\n    CALLS_READ(\"calls:read\", \"View information about ongoing and past calls\", false),\n    CALLS_WRITE(\"calls:write\", \"Start and manage calls in a workspace\", false),\n    CHANNELS_HISTORY(\"channels:history\", \"View messages and other content in public channels that your slack app has been added to\", false),\n    CHANNELS_JOIN(\"channels:join\", \"Join public channels in a workspace\", false),\n    CHANNELS_MANAGE(\"channels:manage\", \"Manage public channels that your slack app has been added to and create new ones\", false),\n    CHANNELS_READ(\"channels:read\", \"View basic information about public channels in a workspace\", false),\n    CHANNELS_WRITE(\"channels:write\", \"Manage a user’s public channels and create new ones on a user’s behalf\", false),\n    CHAT_WRITE(\"chat:write\", \"Post messages in approved channels & conversations\", false),\n    CHAT_WRITE_CUSTOMIZE(\"chat:write.customize\", \"Send messages as @your_slack_app with a customized username and avatar\", false),\n    CHAT_WRITE_PUBLIC(\"chat:write.public\", \"Send messages to channels @your_slack_app isn't a member of\", false),\n    CHAT_WRITE_BOT(\"chat:write:bot\", \"Send messages as your slack app\", false),\n    CHAT_WRITE_USER(\"chat:write:user\", \"Send messages on a user’s behalf\", false),\n    CLIENT(\"client\", \"Receive all events from a workspace in real time\", false),\n    COMMANDS(\"commands\", \"Add shortcuts and/or slash commands that people can use\", false),\n    CONVERSATIONS_HISTORY(\"conversations:history\", \"Deprecated: Retrieve conversation history for legacy workspace apps\", false),\n    CONVERSATIONS_READ(\"conversations:read\", \"Deprecated: Retrieve information on conversations for legacy workspace apps\", false),\n    CONVERSATIONS_WRITE(\"conversations:write\", \"Deprecated: Edit conversation attributes for legacy workspace apps\", false),\n    DND_READ(\"dnd:read\", \"View Do Not Disturb settings for people in a workspace\", false),\n    DND_WRITE(\"dnd:write\", \"Edit a user’s Do Not Disturb settings\", false),\n    DND_WRITE_USER(\"dnd:write:user\", \"Change the user's Do Not Disturb settings\", false),\n    EMOJI_READ(\"emoji:read\", \"View custom emoji in a workspace\", false),\n    FILES_READ(\"files:read\", \"View files shared in channels and conversations that your slack app has been added to\", false),\n    FILES_WRITE(\"files:write\", \"Upload, edit, and delete files as your slack app\", false),\n    FILES_WRITE_USER(\"files:write:user\", \"Upload, edit, and delete files as your slack app\", false),\n    GROUPS_HISTORY(\"groups:history\", \"View messages and other content in private channels that your slack app has been added to\", false),\n    GROUPS_READ(\"groups:read\", \"View basic information about private channels that your slack app has been added to\", false),\n    GROUPS_WRITE(\"groups:write\", \"Manage private channels that your slack app has been added to and create new ones\", false),\n    IDENTIFY(\"identify\", \"View information about a user’s identity\", false),\n    IDENTITY_AVATAR(\"identity.avatar\", \"View a user’s Slack avatar\", false),\n    IDENTITY_AVATAR_READ_USER(\"identity.avatar:read:user\", \"View the user's profile picture\", false),\n    IDENTITY_BASIC(\"identity.basic\", \"View information about a user’s identity\", false),\n    IDENTITY_EMAIL(\"identity.email\", \"View a user’s email address\", false),\n    IDENTITY_EMAIL_READ_USER(\"identity.email:read:user\", \"This scope is not yet described.\", false),\n    IDENTITY_TEAM(\"identity.team\", \"View a user’s Slack workspace name\", false),\n    IDENTITY_TEAM_READ_USER(\"identity.team:read:user\", \"View the workspace's name, domain, and icon\", false),\n    IDENTITY_READ_USER(\"identity:read:user\", \"This scope is not yet described.\", false),\n    IM_HISTORY(\"im:history\", \"View messages and other content in direct messages that your slack app has been added to\", false),\n    IM_READ(\"im:read\", \"View basic information about direct messages that your slack app has been added to\", false),\n    IM_WRITE(\"im:write\", \"Start direct messages with people\", false),\n    INCOMING_WEBHOOK(\"incoming-webhook\", \"Create one-way webhooks to post messages to a specific channel\", false),\n    LINKS_READ(\"links:read\", \"View  URLs in messages\", false),\n    LINKS_WRITE(\"links:write\", \"Show previews of  URLs in messages\", false),\n    MPIM_HISTORY(\"mpim:history\", \"View messages and other content in group direct messages that your slack app has been added to\", false),\n    MPIM_READ(\"mpim:read\", \"View basic information about group direct messages that your slack app has been added to\", false),\n    MPIM_WRITE(\"mpim:write\", \"Start group direct messages with people\", false),\n    NONE(\"none\", \"Execute methods without needing a scope\", false),\n    PINS_READ(\"pins:read\", \"View pinned content in channels and conversations that your slack app has been added to\", false),\n    PINS_WRITE(\"pins:write\", \"Add and remove pinned messages and files\", false),\n    POST(\"post\", \"Post messages to a workspace\", false),\n    REACTIONS_READ(\"reactions:read\", \"View emoji reactions and their associated content in channels and conversations that your slack app has been added to\", false),\n    REACTIONS_WRITE(\"reactions:write\", \"Add and edit emoji reactions\", false),\n    READ(\"read\", \"View all content in a workspace\", false),\n    REMINDERS_READ(\"reminders:read\", \"View reminders created by your slack app\", false),\n    REMINDERS_READ_USER(\"reminders:read:user\", \"Access reminders created by a user or for a user\", false),\n    REMINDERS_WRITE(\"reminders:write\", \"Add, remove, or mark reminders as complete\", false),\n    REMINDERS_WRITE_USER(\"reminders:write:user\", \"Add, remove, or complete reminders for the user\", false),\n    REMOTE_FILES_READ(\"remote_files:read\", \"View remote files added by the app in a workspace\", false),\n    REMOTE_FILES_SHARE(\"remote_files:share\", \"Share remote files on a user’s behalf\", false),\n    REMOTE_FILES_WRITE(\"remote_files:write\", \"Add, edit, and delete remote files on a user’s behalf\", false),\n    SEARCH_READ(\"search:read\", \"Search a workspace’s content\", false),\n    STARS_READ(\"stars:read\", \"View messages and files that your slack app has starred\", false),\n    STARS_WRITE(\"stars:write\", \"Add or remove stars\", false),\n    TEAM_READ(\"team:read\", \"View the name, email domain, and icon for workspaces your slack app is connected to\", false),\n    TOKENS_BASIC(\"tokens.basic\", \"Execute methods without needing a scope\", false),\n    USERGROUPS_READ(\"usergroups:read\", \"View user groups in a workspace\", false),\n    USERGROUPS_WRITE(\"usergroups:write\", \"Create and manage user groups\", false),\n    WORKFLOW_STEPS_EXECUTE(\"workflow.steps:execute\", \"Add steps that people can use in Workflow Builder\", false);\n\n    private final String scope;\n    private final String description;\n    private final boolean isDefault;\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/enums/scope/AuthStackoverflowScope.java",
    "content": "package me.zhyd.oauth.enums.scope;\n\nimport lombok.AllArgsConstructor;\nimport lombok.Getter;\n\n/**\n * Stackoverflow 平台 OAuth 授权范围\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @version 1.0.0\n * @since 1.0.0\n */\n@Getter\n@AllArgsConstructor\npublic enum AuthStackoverflowScope implements AuthScope {\n\n    /**\n     * {@code scope} 含义，以{@code description} 为准\n     */\n    read_inbox(\"read_inbox\", \"access a user's global inbox\", true),\n    NO_EXPIRY(\"no_expiry\", \"access_token's with this scope do not expire\", false),\n    WRITE_ACCESS(\"write_access\", \"perform write operations as a user\", false),\n    PRIVATE_INFO(\"private_info\", \"access full history of a user's private actions on the site\", false);\n\n    private final String scope;\n    private final String description;\n    private final boolean isDefault;\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/enums/scope/AuthWeChatEnterpriseWebScope.java",
    "content": "package me.zhyd.oauth.enums.scope;\n\nimport lombok.AllArgsConstructor;\nimport lombok.Getter;\n\n/**\n * 企业自建应用授权范围\n *\n * @author liguanhua (347826496(a)qq.com)\n * @since 1.15.9\n */\n@Getter\n@AllArgsConstructor\npublic enum AuthWeChatEnterpriseWebScope implements AuthScope {\n    /**\n     * {@code scope} 含义，以{@code description} 为准\n     */\n    SNSAPI_BASE(\"snsapi_base\", \"应用授权作用域。企业自建应用固定填写：snsapi_base\", true);\n\n    private final String scope;\n    private final String description;\n    private final boolean isDefault;\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/enums/scope/AuthWechatMpScope.java",
    "content": "package me.zhyd.oauth.enums.scope;\n\nimport lombok.AllArgsConstructor;\nimport lombok.Getter;\n\n/**\n * 微信公众平台 OAuth 授权范围\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @version 1.0.0\n * @since 1.0.0\n */\n@Getter\n@AllArgsConstructor\npublic enum AuthWechatMpScope implements AuthScope {\n    /**\n     * {@code scope} 含义，以{@code description} 为准\n     */\n    SNSAPI_USERINFO(\"snsapi_userinfo\", \"弹出授权页面，可通过openid拿到昵称、性别、所在地。并且， 即使在未关注的情况下，只要用户授权，也能获取其信息\", true),\n    SNSAPI_BASE(\"snsapi_base\", \"不弹出授权页面，直接跳转，只能获取用户openid\", false);\n\n    private final String scope;\n    private final String description;\n    private final boolean isDefault;\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/enums/scope/AuthWeiboScope.java",
    "content": "package me.zhyd.oauth.enums.scope;\n\nimport lombok.AllArgsConstructor;\nimport lombok.Getter;\n\n/**\n * 微博平台 OAuth 授权范围\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @version 1.0.0\n * @since 1.0.0\n */\n@Getter\n@AllArgsConstructor\npublic enum AuthWeiboScope implements AuthScope {\n\n    /**\n     * {@code scope} 含义，以{@code description} 为准\n     */\n    ALL(\"all\", \"获取所有权限\", true),\n    EMAIL(\"email\", \"用户的联系邮箱，<a rel=\\\"nofollow\\\" href=\\\"http://open.weibo.com/wiki/2/account/profile/email\\\">接口文档</a>\", false),\n    DIRECT_MESSAGES_WRITE(\"direct_messages_write\", \"私信发送接口，<a rel=\\\"nofollow\\\" href=\\\"http://open.weibo.com/wiki/C/2/direct_messages/send\\\">接口文档</a>\", false),\n    DIRECT_MESSAGES_READ(\"direct_messages_read\", \"私信读取接口，<a rel=\\\"nofollow\\\" href=\\\"http://open.weibo.com/wiki/C/2/direct_messages\\\">接口文档</a>\", false),\n    INVITATION_WRITE(\"invitation_write\", \"邀请发送接口，<a rel=\\\"nofollow\\\" href=\\\"http://open.weibo.com/wiki/Messages#.E5.A5.BD.E5.8F.8B.E9.82.80.E8.AF.B7\\\">接口文档</a>\", false),\n    FRIENDSHIPS_GROUPS_READ(\"friendships_groups_read\", \"好友分组读取接口组，<a rel=\\\"nofollow\\\" href=\\\"http://open.weibo.com/wiki/API%E6%96%87%E6%A1%A3_V2#.E5.A5.BD.E5.8F.8B.E5.88.86.E7.BB.84\\\">接口文档</a>\", false),\n    FRIENDSHIPS_GROUPS_WRITE(\"friendships_groups_write\", \"好友分组写入接口组，<a rel=\\\"nofollow\\\" href=\\\"http://open.weibo.com/wiki/API%E6%96%87%E6%A1%A3_V2#.E5.A5.BD.E5.8F.8B.E5.88.86.E7.BB.84\\\">接口文档</a>\", false),\n    STATUSES_TO_ME_READ(\"statuses_to_me_read\", \"定向微博读取接口组，<a rel=\\\"nofollow\\\" href=\\\"http://open.weibo.com/wiki/API%E6%96%87%E6%A1%A3_V2#.E5.BE.AE.E5.8D.9A\\\">接口文档</a>\", false),\n    FOLLOW_APP_OFFICIAL_MICROBLOG(\"follow_app_official_microblog\", \"关注应用官方微博，该参数不对应具体接口，只需在应用控制台填写官方帐号即可。填写的路径：我的应用-选择自己的应用-应用信息-基本信息-官方运营账号（默认值是应用开发者帐号）\", false);\n\n    private final String scope;\n    private final String description;\n    private final boolean isDefault;\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/enums/scope/package-info.java",
    "content": "/**\n * 各个平台的授权范围\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @version 1.0.0\n * @since 1.15.7\n */\npackage me.zhyd.oauth.enums.scope;\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/exception/AuthException.java",
    "content": "package me.zhyd.oauth.exception;\n\nimport me.zhyd.oauth.config.AuthSource;\nimport me.zhyd.oauth.enums.AuthResponseStatus;\n\n/**\n * JustAuth通用异常类\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.8\n */\npublic class AuthException extends RuntimeException {\n\n    private int errorCode;\n    private String errorMsg;\n\n    public AuthException(String errorMsg) {\n        this(AuthResponseStatus.FAILURE.getCode(), errorMsg);\n    }\n\n    public AuthException(String errorMsg, AuthSource source) {\n        this(AuthResponseStatus.FAILURE.getCode(), errorMsg, source);\n    }\n\n    public AuthException(int errorCode, String errorMsg) {\n        super(errorMsg);\n        this.errorCode = errorCode;\n        this.errorMsg = errorMsg;\n    }\n\n    public AuthException(AuthResponseStatus status) {\n        this(status.getCode(), status.getMsg());\n    }\n\n    public AuthException(int errorCode, String errorMsg, AuthSource source) {\n        this(errorCode, String.format(\"%s [%s]\", errorMsg, source.getName()));\n    }\n\n    public AuthException(AuthResponseStatus status, AuthSource source) {\n        this(status.getCode(), status.getMsg(), source);\n    }\n\n    public AuthException(String message, Throwable cause) {\n        super(message, cause);\n    }\n\n    public AuthException(Throwable cause) {\n        super(cause);\n    }\n\n    public int getErrorCode() {\n        return errorCode;\n    }\n\n    public String getErrorMsg() {\n        return errorMsg;\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/exception/package-info.java",
    "content": "/**\n * JustAuth专用异常封装\n */\npackage me.zhyd.oauth.exception;\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/log/Log.java",
    "content": "package me.zhyd.oauth.log;\n\nimport lombok.AllArgsConstructor;\nimport lombok.Getter;\n\nimport java.io.PrintStream;\nimport java.time.LocalDateTime;\nimport java.time.format.DateTimeFormatter;\n\n/**\n * 针对JustAuth提供的轻量级的日志打印工具\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @see Log#debug(String)\n * @see Log#debug(String, Throwable)\n * @see Log#warn(String)\n * @see Log#warn(String, Throwable)\n * @see Log#error(String)\n * @see Log#error(String, Throwable)\n * @since 1.10.0\n */\npublic class Log {\n\n    public static void debug(String msg) {\n        debug(msg, null);\n    }\n\n    public static void warn(String msg) {\n        warn(msg, null);\n    }\n\n    public static void error(String msg) {\n        error(msg, null);\n    }\n\n    public static void debug(String msg, Throwable t) {\n        print(Level.DEBUG, msg, t, System.out);\n    }\n\n    public static void warn(String msg, Throwable t) {\n        print(Level.WARN, msg, t, System.out);\n    }\n\n    public static void error(String msg, Throwable t) {\n        print(Level.ERROR, msg, t, System.err);\n    }\n\n    /**\n     * 打印日志内容，格式：2019-08-02 20:44:07 main me.zhyd.oauth.log.Log(debug:39) [DEBUG] - xxxx\n     *\n     * @param level 日志级别\n     * @param msg   日志内容\n     * @param t     异常信息\n     * @param ps    实际执行打印的PrintStream\n     */\n    private static void print(Level level, String msg, Throwable t, PrintStream ps) {\n        if (Config.enable) {\n            if (level.getLevelNum() >= Config.level.getLevelNum()) {\n                ps.println(String.format(\"%s %s %s [%s] - %s\", getDate(), Thread.currentThread().getName(), getCaller(), level, msg));\n                writeThrowable(t, ps);\n                ps.flush();\n            }\n        }\n    }\n\n    /**\n     * 获取调用方的信息\n     *\n     * @return 返回调用方的信息，格式：class(method:lineNumber)\n     */\n    private static String getCaller() {\n        int offset = 2;\n        StackTraceElement[] stackTraceArr = (new Throwable()).getStackTrace();\n        StackTraceElement stackTrace = null;\n        if (offset >= stackTraceArr.length) {\n            offset = offset - 1;\n        }\n        stackTrace = stackTraceArr[offset];\n        return stackTrace.getClassName() +\n            \"(\" +\n            stackTrace.getMethodName() +\n            ':' +\n            stackTrace.getLineNumber() +\n            \")\";\n    }\n\n    /**\n     * 获取格式化后的日期\n     *\n     * @return string\n     */\n    private static String getDate() {\n        return LocalDateTime.now().format(DateTimeFormatter.ofPattern(\"yyyy-MM-dd HH:mm:ss\"));\n    }\n\n    /**\n     * 打印异常信息\n     *\n     * @param t            异常\n     * @param targetStream 实际执行打印的PrintStream\n     */\n    private static void writeThrowable(Throwable t, PrintStream targetStream) {\n        if (t != null) {\n            t.printStackTrace(targetStream);\n        }\n    }\n\n    /**\n     * 日志级别\n     *\n     * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n     * @since 1.10.0\n     */\n    @Getter\n    @AllArgsConstructor\n    public enum Level {\n        /**\n         * DEBUG: 普通级别\n         */\n        DEBUG(10),\n        /**\n         * WARN: 警告级别\n         */\n        WARN(30),\n        /**\n         * ERROR: 异常级别\n         */\n        ERROR(40);\n\n        private int levelNum;\n    }\n\n    /**\n     * 日志配置\n     *\n     * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n     * @since 1.10.0\n     */\n    public static class Config {\n\n        /**\n         * 需要打印的日志级别\n         */\n        public static Level level = Level.DEBUG;\n        /**\n         * 是否启用日志打印功能，默认启用\n         */\n        public static boolean enable = true;\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/log/package-info.java",
    "content": "/**\n * 针对JustAuth简单封装的日志打印工具，可用过{@link me.zhyd.oauth.config.JustAuthLogConfig}开关日志和指定日志级别\n */\npackage me.zhyd.oauth.log;\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/model/AuthCallback.java",
    "content": "package me.zhyd.oauth.model;\n\nimport lombok.AllArgsConstructor;\nimport lombok.Builder;\nimport lombok.Getter;\nimport lombok.NoArgsConstructor;\nimport lombok.Setter;\nimport me.zhyd.oauth.utils.StringUtils;\n\nimport java.io.Serializable;\n\n/**\n * 授权回调时的参数类\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.8.0\n */\n@Getter\n@Setter\n@Builder\n@AllArgsConstructor\n@NoArgsConstructor\npublic class AuthCallback implements Serializable {\n\n    /**\n     * 访问AuthorizeUrl后回调时带的参数code\n     */\n    private String code;\n\n    /**\n     * 访问AuthorizeUrl后回调时带的参数auth_code，该参数目前只使用于支付宝登录\n     */\n    private String auth_code;\n\n    /**\n     * 访问AuthorizeUrl后回调时带的参数state，用于和请求AuthorizeUrl前的state比较，防止CSRF攻击\n     */\n    private String state;\n\n    /**\n     * 华为授权登录接受code的参数名\n     *\n     * @since 1.10.0\n     */\n    private String authorization_code;\n\n    /**\n     * Twitter回调后返回的oauth_token\n     *\n     * @since 1.13.0\n     */\n    private String oauth_token;\n\n    /**\n     * Twitter回调后返回的oauth_verifier\n     *\n     * @since 1.13.0\n     */\n    private String oauth_verifier;\n\n    /**\n     * 苹果仅在用户首次授权应用程序时返回此值。如果您的应用程序已经获得了用户的授权，那么苹果将不会再次返回此值\n     * @see <a href=\"https://developer.apple.com/documentation/sign_in_with_apple/useri\">user info</a>\n     */\n    private String user;\n\n    /**\n     * 苹果错误信息，仅在用户取消授权时返回此值\n     * @see <a href=\"https://developer.apple.com/documentation/sign_in_with_apple/sign_in_with_apple_js/incorporating_sign_in_with_apple_into_other_platforms\">error response</a>\n     */\n    private String error;\n\n    public String getCode() {\n        return StringUtils.isEmpty(code) ? auth_code : code;\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/model/AuthResponse.java",
    "content": "package me.zhyd.oauth.model;\n\nimport lombok.*;\nimport me.zhyd.oauth.enums.AuthResponseStatus;\n\nimport java.io.Serializable;\n\n/**\n * JustAuth统一授权响应类\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.8\n */\n@Getter\n@Setter\n@Builder\n@NoArgsConstructor\n@AllArgsConstructor\npublic class AuthResponse<T> implements Serializable {\n    /**\n     * 授权响应状态码\n     */\n    private int code;\n\n    /**\n     * 授权响应信息\n     */\n    private String msg;\n\n    /**\n     * 授权响应数据，当且仅当 code = 2000 时返回\n     */\n    private T data;\n\n    /**\n     * 是否请求成功\n     *\n     * @return true or false\n     */\n    public boolean ok() {\n        return this.code == AuthResponseStatus.SUCCESS.getCode();\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/model/AuthToken.java",
    "content": "package me.zhyd.oauth.model;\n\nimport lombok.*;\n\nimport java.io.Serializable;\n\n/**\n * 授权所需的token\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.8\n */\n@Getter\n@Setter\n@Builder\n@NoArgsConstructor\n@AllArgsConstructor\npublic class AuthToken implements Serializable {\n    private String accessToken;\n    private int expireIn;\n    private String refreshToken;\n    private int refreshTokenExpireIn;\n    private String uid;\n    private String openId;\n    private String accessCode;\n    private String unionId;\n\n    /**\n     * Google附带属性\n     */\n    private String scope;\n    private String tokenType;\n    private String idToken;\n\n    /**\n     * 小米附带属性\n     */\n    private String macAlgorithm;\n    private String macKey;\n\n    /**\n     * 企业微信附带属性\n     *\n     * @since 1.10.0\n     */\n    private String code;\n    /**\n     * 微信公众号 - 网页授权的登录时可用\n     *\n     * 微信针对网页授权登录，增加了一个快照页的逻辑，快照页获取到的微信用户的 uid oid 和头像昵称都是虚拟的信息\n     */\n    private boolean snapshotUser;\n\n    /**\n     * Twitter附带属性\n     *\n     * @since 1.13.0\n     */\n    private String oauthToken;\n    private String oauthTokenSecret;\n    private String userId;\n    private String screenName;\n    private Boolean oauthCallbackConfirmed;\n\n    /**\n     * Apple附带属性\n     */\n    private String username;\n\n    /**\n     * 新版钉钉附带属性\n     *\n     * @since 1.16.7\n     */\n    private String corpId;\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/model/AuthUser.java",
    "content": "package me.zhyd.oauth.model;\n\nimport com.alibaba.fastjson.JSONObject;\nimport lombok.*;\nimport me.zhyd.oauth.enums.AuthUserGender;\nimport java.io.Serializable;\n\n/**\n * 授权成功后的用户信息，根据授权平台的不同，获取的数据完整性也不同\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.8\n */\n@Getter\n@Setter\n@Builder\n@NoArgsConstructor\n@AllArgsConstructor\npublic class AuthUser implements Serializable {\n    /**\n     * 用户第三方系统的唯一id。在调用方集成该组件时，可以用uuid + source唯一确定一个用户\n     *\n     * @since 1.3.3\n     */\n    private String uuid;\n    /**\n     * 用户名\n     */\n    private String username;\n    /**\n     * 用户昵称\n     */\n    private String nickname;\n    /**\n     * 用户头像\n     */\n    private String avatar;\n    /**\n     * 用户网址\n     */\n    private String blog;\n    /**\n     * 所在公司\n     */\n    private String company;\n    /**\n     * 位置\n     */\n    private String location;\n    /**\n     * 用户邮箱\n     */\n    private String email;\n    /**\n     * 用户备注（各平台中的用户个人介绍）\n     */\n    private String remark;\n    /**\n     * 性别\n     */\n    private AuthUserGender gender;\n    /**\n     * 用户来源\n     */\n    private String source;\n    /**\n     * 用户授权的token信息\n     */\n    private AuthToken token;\n    /**\n     * 第三方平台返回的原始用户信息\n     */\n    private JSONObject rawUserInfo;\n\n    /**\n     * 微信公众号 - 网页授权的登录时可用\n     *\n     * 微信针对网页授权登录，增加了一个快照页的逻辑，快照页获取到的微信用户的 uid oid 和头像昵称都是虚拟的信息\n     */\n    private boolean snapshotUser;\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/model/package-info.java",
    "content": "/**\n * JustAuth核心模型类，封装了用户、token、响应和callback等实体类\n */\npackage me.zhyd.oauth.model;\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/package-info.java",
    "content": "/**\n * JustAuth，如你所见，它仅仅是一个第三方授权登录的工具类库，它可以让我们脱离繁琐的第三方登录SDK，让登录变得So easy!\n * <p>\n * 史上最全的整合第三方登录的开源库。目前已支持Github、Gitee、微博、钉钉、百度、Coding、腾讯云开发者平台、OSChina、\n * 支付宝、QQ、微信、淘宝、Google、Facebook、抖音、领英、小米、微软、今日头条、Teambition、StackOverflow、Pinterest、\n * 人人、华为和企业微信等第三方平台的授权登录。 Login, so easy!\n */\npackage me.zhyd.oauth;\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AbstractAuthDingtalkRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSON;\nimport com.alibaba.fastjson.JSONObject;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthSource;\nimport me.zhyd.oauth.enums.AuthUserGender;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.GlobalAuthUtils;\nimport me.zhyd.oauth.utils.HttpUtils;\nimport me.zhyd.oauth.utils.UrlBuilder;\n\n/**\n * <p>\n * 钉钉登录抽象类，负责处理使用钉钉账号登录第三方网站和扫码登录第三方网站两种钉钉的登录方式\n * </p>\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.16.0\n */\npublic abstract class AbstractAuthDingtalkRequest extends AuthDefaultRequest {\n\n    public AbstractAuthDingtalkRequest(AuthConfig config, AuthSource source) {\n        super(config, source);\n    }\n\n\n    public AbstractAuthDingtalkRequest(AuthConfig config, AuthSource source, AuthStateCache authStateCache) {\n        super(config, source, authStateCache);\n    }\n\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        return AuthToken.builder().accessCode(authCallback.getCode()).build();\n    }\n\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        String code = authToken.getAccessCode();\n        JSONObject param = new JSONObject();\n        param.put(\"tmp_auth_code\", code);\n        String response = new HttpUtils(config.getHttpConfig()).post(userInfoUrl(authToken), param.toJSONString()).getBody();\n        JSONObject object = JSON.parseObject(response);\n        if (object.getIntValue(\"errcode\") != 0) {\n            throw new AuthException(object.getString(\"errmsg\"));\n        }\n        object = object.getJSONObject(\"user_info\");\n        AuthToken token = AuthToken.builder()\n            .openId(object.getString(\"openid\"))\n            .unionId(object.getString(\"unionid\"))\n            .build();\n        return AuthUser.builder()\n            .rawUserInfo(object)\n            .uuid(object.getString(\"unionid\"))\n            .nickname(object.getString(\"nick\"))\n            .username(object.getString(\"nick\"))\n            .gender(AuthUserGender.UNKNOWN)\n            .source(source.toString())\n            .token(token)\n            .build();\n    }\n\n    /**\n     * 返回带{@code state}参数的授权url，授权回调时会带上这个{@code state}\n     *\n     * @param state state 验证授权流程的参数，可以防止csrf\n     * @return 返回授权地址\n     * @since 1.9.3\n     */\n    @Override\n    public String authorize(String state) {\n        return UrlBuilder.fromBaseUrl(source.authorize())\n            .queryParam(\"response_type\", \"code\")\n            .queryParam(\"appid\", config.getClientId())\n            .queryParam(\"scope\", \"snsapi_login\")\n            .queryParam(\"redirect_uri\", config.getRedirectUri())\n            .queryParam(\"state\", getRealState(state))\n            .build();\n    }\n\n    /**\n     * 返回获取userInfo的url\n     *\n     * @param authToken 用户授权后的token\n     * @return 返回获取userInfo的url\n     */\n    @Override\n    protected String userInfoUrl(AuthToken authToken) {\n        // 根据timestamp, appSecret计算签名值\n        String timestamp = System.currentTimeMillis() + \"\";\n        String urlEncodeSignature = GlobalAuthUtils.generateDingTalkSignature(config.getClientSecret(), timestamp);\n\n        return UrlBuilder.fromBaseUrl(source.userInfo())\n            .queryParam(\"signature\", urlEncodeSignature)\n            .queryParam(\"timestamp\", timestamp)\n            .queryParam(\"accessKey\", config.getClientId())\n            .build();\n    }\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AbstractAuthMicrosoftRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONObject;\nimport com.xkcoding.http.support.HttpHeader;\nimport com.xkcoding.http.util.MapUtil;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthSource;\nimport me.zhyd.oauth.enums.AuthResponseStatus;\nimport me.zhyd.oauth.enums.AuthUserGender;\nimport me.zhyd.oauth.enums.scope.AuthMicrosoftScope;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthResponse;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.AuthScopeUtils;\nimport me.zhyd.oauth.utils.HttpUtils;\nimport me.zhyd.oauth.utils.StringUtils;\nimport me.zhyd.oauth.utils.UrlBuilder;\n\nimport java.util.Map;\n\n/**\n * 微软登录抽象类,负责处理使用微软国际和微软中国账号登录第三方网站的登录方式\n *\n * @author mroldx (xzfqq5201314@gmail.com)\n * @since 1.16.4\n */\npublic abstract class AbstractAuthMicrosoftRequest extends AuthDefaultRequest {\n\n    public AbstractAuthMicrosoftRequest(AuthConfig config, AuthSource source) {\n        super(config, source);\n    }\n\n\n    public AbstractAuthMicrosoftRequest(AuthConfig config, AuthSource source, AuthStateCache authStateCache) {\n        super(config, source, authStateCache);\n    }\n\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        return getToken(accessTokenUrl(authCallback.getCode()));\n    }\n\n    /**\n     * 获取token，适用于获取access_token和刷新token\n     *\n     * @param accessTokenUrl 实际请求token的地址\n     * @return token对象\n     */\n    private AuthToken getToken(String accessTokenUrl) {\n        HttpHeader httpHeader = new HttpHeader();\n\n        Map<String, String> form = MapUtil.parseStringToMap(accessTokenUrl, false);\n\n        String response = new HttpUtils(config.getHttpConfig()).post(accessTokenUrl, form, httpHeader, false).getBody();\n        JSONObject accessTokenObject = JSONObject.parseObject(response);\n\n        this.checkResponse(accessTokenObject);\n\n        return AuthToken.builder()\n            .accessToken(accessTokenObject.getString(\"access_token\"))\n            .expireIn(accessTokenObject.getIntValue(\"expires_in\"))\n            .scope(accessTokenObject.getString(\"scope\"))\n            .tokenType(accessTokenObject.getString(\"token_type\"))\n            .refreshToken(accessTokenObject.getString(\"refresh_token\"))\n            .build();\n    }\n\n    /**\n     * 检查响应内容是否正确\n     *\n     * @param object 请求响应内容\n     */\n    private void checkResponse(JSONObject object) {\n        if (object.containsKey(\"error\")) {\n            throw new AuthException(object.getString(\"error_description\"));\n        }\n    }\n\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        String token = authToken.getAccessToken();\n        String tokenType = authToken.getTokenType();\n        String jwt = tokenType + \" \" + token;\n\n        HttpHeader httpHeader = new HttpHeader();\n        httpHeader.add(\"Authorization\", jwt);\n\n        String userInfo = new HttpUtils(config.getHttpConfig()).get(userInfoUrl(authToken), null, httpHeader, false).getBody();\n        JSONObject object = JSONObject.parseObject(userInfo);\n        this.checkResponse(object);\n        return AuthUser.builder()\n            .rawUserInfo(object)\n            .uuid(object.getString(\"id\"))\n            .username(object.getString(\"userPrincipalName\"))\n            .nickname(object.getString(\"displayName\"))\n            .location(object.getString(\"officeLocation\"))\n            .email(object.getString(\"mail\"))\n            .gender(AuthUserGender.UNKNOWN)\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n\n    /**\n     * 刷新access token （续期）\n     *\n     * @param authToken 登录成功后返回的Token信息\n     * @return AuthResponse\n     */\n    @Override\n    public AuthResponse<AuthToken> refresh(AuthToken authToken) {\n        return AuthResponse.<AuthToken>builder()\n            .code(AuthResponseStatus.SUCCESS.getCode())\n            .data(getToken(refreshTokenUrl(authToken.getRefreshToken())))\n            .build();\n    }\n\n    /**\n     * 返回带{@code state}参数的授权url，授权回调时会带上这个{@code state}\n     *\n     * @param state state 验证授权流程的参数，可以防止csrf\n     * @return 返回授权地址\n     * @since 1.9.3\n     */\n    @Override\n    public String authorize(String state) {\n        // 兼容 Microsoft Entra ID 登录（原微软 AAD）\n        // @since 1.16.6\n        String tenantId = StringUtils.isEmpty(config.getTenantId()) ? \"common\" : config.getTenantId();\n        return UrlBuilder.fromBaseUrl(String.format(source.authorize(), tenantId))\n            .queryParam(\"response_type\", \"code\")\n            .queryParam(\"client_id\", config.getClientId())\n            .queryParam(\"redirect_uri\", config.getRedirectUri())\n            .queryParam(\"state\", getRealState(state))\n            .queryParam(\"response_mode\", \"query\")\n            .queryParam(\"scope\", this.getScopes(\" \", false, AuthScopeUtils.getDefaultScopes(AuthMicrosoftScope.values())))\n            .build();\n    }\n\n    /**\n     * 返回获取accessToken的url\n     *\n     * @param code 授权code\n     * @return 返回获取accessToken的url\n     */\n    @Override\n    protected String accessTokenUrl(String code) {\n        String tenantId = StringUtils.isEmpty(config.getTenantId()) ? \"common\" : config.getTenantId();\n        return UrlBuilder.fromBaseUrl(String.format(source.accessToken(), tenantId))\n            .queryParam(\"code\", code)\n            .queryParam(\"client_id\", config.getClientId())\n            .queryParam(\"client_secret\", config.getClientSecret())\n            .queryParam(\"grant_type\", \"authorization_code\")\n            .queryParam(\"scope\", this.getScopes(\" \", false, AuthScopeUtils.getDefaultScopes(AuthMicrosoftScope.values())))\n            .queryParam(\"redirect_uri\", config.getRedirectUri())\n            .build();\n    }\n\n    /**\n     * 返回获取userInfo的url\n     *\n     * @param authToken 用户授权后的token\n     * @return 返回获取userInfo的url\n     */\n    @Override\n    protected String userInfoUrl(AuthToken authToken) {\n        return UrlBuilder.fromBaseUrl(source.userInfo()).build();\n    }\n\n    /**\n     * 返回获取accessToken的url\n     *\n     * @param refreshToken 用户授权后的token\n     * @return 返回获取accessToken的url\n     */\n    @Override\n    protected String refreshTokenUrl(String refreshToken) {\n        String tenantId = StringUtils.isEmpty(config.getTenantId()) ? \"common\" : config.getTenantId();\n        return UrlBuilder.fromBaseUrl(String.format(source.refresh(), tenantId))\n            .queryParam(\"client_id\", config.getClientId())\n            .queryParam(\"client_secret\", config.getClientSecret())\n            .queryParam(\"refresh_token\", refreshToken)\n            .queryParam(\"grant_type\", \"refresh_token\")\n            .queryParam(\"scope\", this.getScopes(\" \", false, AuthScopeUtils.getDefaultScopes(AuthMicrosoftScope.values())))\n            .queryParam(\"redirect_uri\", config.getRedirectUri())\n            .build();\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AbstractAuthWeChatEnterpriseRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONObject;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthSource;\nimport me.zhyd.oauth.enums.AuthResponseStatus;\nimport me.zhyd.oauth.enums.AuthUserGender;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.HttpUtils;\nimport me.zhyd.oauth.utils.StringUtils;\nimport me.zhyd.oauth.utils.UrlBuilder;\n\n/**\n * <p>\n * 企业微信登录父类\n * </p>\n *\n * @author liguanhua (347826496(a)qq.com)\n * @since 1.15.9\n */\npublic abstract class AbstractAuthWeChatEnterpriseRequest extends AuthDefaultRequest {\n\n    public AbstractAuthWeChatEnterpriseRequest(AuthConfig config, AuthSource source) {\n        super(config,source);\n    }\n\n\n    public AbstractAuthWeChatEnterpriseRequest(AuthConfig config, AuthSource source, AuthStateCache authStateCache) {\n        super(config, source, authStateCache);\n    }\n\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        String response = doGetAuthorizationCode(accessTokenUrl(null));\n\n        JSONObject object = this.checkResponse(response);\n\n        return AuthToken.builder()\n            .accessToken(object.getString(\"access_token\"))\n            .expireIn(object.getIntValue(\"expires_in\"))\n            .code(authCallback.getCode())\n            .build();\n    }\n\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        String response = doGetUserInfo(authToken);\n        JSONObject object = this.checkResponse(response);\n\n        // 返回 OpenId 或其他，均代表非当前企业用户，不支持\n        if (!object.containsKey(\"UserId\")) {\n            throw new AuthException(AuthResponseStatus.UNIDENTIFIED_PLATFORM, source);\n        }\n        String userId = object.getString(\"UserId\");\n        String userTicket = object.getString(\"user_ticket\");\n        JSONObject userDetail = getUserDetail(authToken.getAccessToken(), userId, userTicket);\n\n        return AuthUser.builder()\n            .rawUserInfo(userDetail)\n            .username(userDetail.getString(\"name\"))\n            .nickname(userDetail.getString(\"alias\"))\n            .avatar(userDetail.getString(\"avatar\"))\n            .location(userDetail.getString(\"address\"))\n            .email(userDetail.getString(\"email\"))\n            .uuid(userId)\n            .gender(AuthUserGender.getWechatRealGender(userDetail.getString(\"gender\")))\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n\n    /**\n     * 校验请求结果\n     *\n     * @param response 请求结果\n     * @return 如果请求结果正常，则返回JSONObject\n     */\n    private JSONObject checkResponse(String response) {\n        JSONObject object = JSONObject.parseObject(response);\n\n        if (object.containsKey(\"errcode\") && object.getIntValue(\"errcode\") != 0) {\n            throw new AuthException(object.getString(\"errmsg\"), source);\n        }\n\n        return object;\n    }\n\n\n    /**\n     * 返回获取accessToken的url\n     *\n     * @param code 授权码\n     * @return 返回获取accessToken的url\n     */\n    @Override\n    protected String accessTokenUrl(String code) {\n        return UrlBuilder.fromBaseUrl(source.accessToken())\n            .queryParam(\"corpid\", config.getClientId())\n            .queryParam(\"corpsecret\", config.getClientSecret())\n            .build();\n    }\n\n    /**\n     * 返回获取userInfo的url\n     *\n     * @param authToken 用户授权后的token\n     * @return 返回获取userInfo的url\n     */\n    @Override\n    protected String userInfoUrl(AuthToken authToken) {\n        return UrlBuilder.fromBaseUrl(source.userInfo())\n            .queryParam(\"access_token\", authToken.getAccessToken())\n            .queryParam(\"code\", authToken.getCode())\n            .build();\n    }\n\n    /**\n     * 用户详情\n     *\n     * @param accessToken accessToken\n     * @param userId      企业内用户id\n     * @param userTicket  成员票据，用于获取用户信息或敏感信息\n     * @return 用户详情\n     */\n    private JSONObject getUserDetail(String accessToken, String userId, String userTicket) {\n        // 用户基础信息\n        String userInfoUrl = UrlBuilder.fromBaseUrl(\"https://qyapi.weixin.qq.com/cgi-bin/user/get\")\n            .queryParam(\"access_token\", accessToken)\n            .queryParam(\"userid\", userId)\n            .build();\n        String userInfoResponse = new HttpUtils(config.getHttpConfig()).get(userInfoUrl).getBody();\n        JSONObject userInfo = checkResponse(userInfoResponse);\n\n        // 用户敏感信息\n        if (StringUtils.isNotEmpty(userTicket)) {\n            String userDetailUrl = UrlBuilder.fromBaseUrl(\"https://qyapi.weixin.qq.com/cgi-bin/auth/getuserdetail\")\n                .queryParam(\"access_token\", accessToken)\n                .build();\n            JSONObject param = new JSONObject();\n            param.put(\"user_ticket\", userTicket);\n            String userDetailResponse = new HttpUtils(config.getHttpConfig()).post(userDetailUrl, param.toJSONString()).getBody();\n            JSONObject userDetail = checkResponse(userDetailResponse);\n\n            userInfo.putAll(userDetail);\n        }\n        return userInfo;\n    }\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthAfDianRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONObject;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.enums.AuthUserGender;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.HttpUtils;\nimport me.zhyd.oauth.utils.UrlBuilder;\n\nimport java.util.HashMap;\nimport java.util.Map;\n\n/**\n * 爱发电\n *\n * @author handy\n */\npublic class AuthAfDianRequest extends AuthDefaultRequest {\n\n    public AuthAfDianRequest(AuthConfig config) {\n        super(config, AuthDefaultSource.AFDIAN);\n    }\n\n    public AuthAfDianRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.AFDIAN, authStateCache);\n    }\n\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        Map<String, String> params = new HashMap<>();\n        params.put(\"grant_type\", \"authorization_code\");\n        params.put(\"client_id\", config.getClientId());\n        params.put(\"client_secret\", config.getClientSecret());\n        params.put(\"code\", authCallback.getCode());\n        params.put(\"redirect_uri\", config.getRedirectUri());\n        String response = new HttpUtils(config.getHttpConfig()).post(AuthDefaultSource.AFDIAN.accessToken(), params, false).getBody();\n        JSONObject accessTokenObject = JSONObject.parseObject(response);\n        String userId = accessTokenObject.getJSONObject(\"data\").getString(\"user_id\");\n        return AuthToken.builder().userId(userId).build();\n    }\n\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        return AuthUser.builder()\n            .uuid(authToken.getUserId())\n            .gender(AuthUserGender.UNKNOWN)\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n\n    /**\n     * 返回带{@code state}参数的授权url，授权回调时会带上这个{@code state}\n     *\n     * @param state state 验证授权流程的参数，可以防止csrf\n     * @return 返回授权地址\n     */\n    @Override\n    public String authorize(String state) {\n        return UrlBuilder.fromBaseUrl(source.authorize())\n            .queryParam(\"response_type\", \"code\")\n            .queryParam(\"scope\", \"basic\")\n            .queryParam(\"client_id\", config.getClientId())\n            .queryParam(\"redirect_uri\", config.getRedirectUri())\n            .queryParam(\"state\", getRealState(state))\n            .build();\n    }\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthAlipayCertRequest.java",
    "content": "package me.zhyd.oauth.request;\n\n\nimport com.alibaba.fastjson.JSONObject;\nimport com.alipay.api.AlipayApiException;\nimport com.alipay.api.AlipayClient;\nimport com.alipay.api.AlipayConfig;\nimport com.alipay.api.DefaultAlipayClient;\nimport com.alipay.api.request.AlipaySystemOauthTokenRequest;\nimport com.alipay.api.request.AlipayUserInfoShareRequest;\nimport com.alipay.api.response.AlipaySystemOauthTokenResponse;\nimport com.alipay.api.response.AlipayUserInfoShareResponse;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.enums.AuthResponseStatus;\nimport me.zhyd.oauth.enums.AuthUserGender;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthResponse;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.StringUtils;\nimport me.zhyd.oauth.utils.UrlBuilder;\n\nimport static me.zhyd.oauth.config.AuthDefaultSource.ALIPAY;\n\n/**\n * 支付宝证书模式登录\n *\n * @since 1.16.7\n */\npublic class AuthAlipayCertRequest extends AuthDefaultRequest {\n\n    private final AlipayClient alipayClient;\n\n    public AuthAlipayCertRequest(AuthConfig config, AlipayConfig alipayConfig) {\n        super(config, ALIPAY);\n        try {\n            this.alipayClient = new DefaultAlipayClient(alipayConfig);\n        } catch (AlipayApiException e) {\n            throw new AuthException(e);\n        }\n    }\n\n    @Override\n    protected void checkCode(AuthCallback authCallback) {\n        if (StringUtils.isEmpty(authCallback.getAuth_code())) {\n            throw new AuthException(AuthResponseStatus.ILLEGAL_CODE, source);\n        }\n    }\n\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        AlipaySystemOauthTokenRequest request = new AlipaySystemOauthTokenRequest();\n        request.setGrantType(\"authorization_code\");\n        request.setCode(authCallback.getAuth_code());\n        AlipaySystemOauthTokenResponse response;\n        try {\n            response = this.alipayClient.certificateExecute(request);\n        } catch (Exception e) {\n            throw new AuthException(e);\n        }\n        if (!response.isSuccess()) {\n            throw new AuthException(response.getSubMsg());\n        }\n        return AuthToken.builder()\n            .accessToken(response.getAccessToken())\n            .uid(response.getUserId())\n            .expireIn(Integer.parseInt(response.getExpiresIn()))\n            .refreshToken(response.getRefreshToken())\n            .build();\n    }\n\n\n    /**\n     * 刷新access token （续期）\n     *\n     * @param authToken 登录成功后返回的Token信息\n     * @return AuthResponse\n     */\n    @Override\n    public AuthResponse<AuthToken> refresh(AuthToken authToken) {\n        AlipaySystemOauthTokenRequest request = new AlipaySystemOauthTokenRequest();\n        request.setGrantType(\"refresh_token\");\n        request.setRefreshToken(authToken.getRefreshToken());\n        AlipaySystemOauthTokenResponse response = null;\n        try {\n            response = this.alipayClient.certificateExecute(request);\n        } catch (Exception e) {\n            throw new AuthException(e);\n        }\n        if (!response.isSuccess()) {\n            throw new AuthException(response.getSubMsg());\n        }\n        return AuthResponse.<AuthToken>builder()\n            .code(AuthResponseStatus.SUCCESS.getCode())\n            .data(AuthToken.builder()\n                .accessToken(response.getAccessToken())\n                .uid(response.getUserId())\n                .expireIn(Integer.parseInt(response.getExpiresIn()))\n                .refreshToken(response.getRefreshToken())\n                .build())\n            .build();\n    }\n\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        String accessToken = authToken.getAccessToken();\n        AlipayUserInfoShareRequest request = new AlipayUserInfoShareRequest();\n        AlipayUserInfoShareResponse response = null;\n        try {\n            response = this.alipayClient.certificateExecute(request, accessToken);\n        } catch (AlipayApiException e) {\n            throw new AuthException(e.getErrMsg(), e);\n        }\n        if (!response.isSuccess()) {\n            throw new AuthException(response.getSubMsg());\n        }\n\n        String province = response.getProvince(), city = response.getCity();\n        String location = String.format(\"%s %s\", StringUtils.isEmpty(province) ? \"\" : province, StringUtils.isEmpty(city) ? \"\" : city);\n\n        return AuthUser.builder()\n            .rawUserInfo(JSONObject.parseObject(JSONObject.toJSONString(response)))\n            .uuid(response.getOpenId())\n            .username(StringUtils.isEmpty(response.getUserName()) ? response.getNickName() : response.getUserName())\n            .nickname(response.getNickName())\n            .avatar(response.getAvatar())\n            .location(location)\n            .gender(AuthUserGender.getRealGender(response.getGender()))\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n\n\n    /**\n     * 返回带{@code state}参数的授权url，授权回调时会带上这个{@code state}\n     *\n     * @param state state 验证授权流程的参数，可以防止csrf\n     * @return 返回授权地址\n     * @since 1.9.3\n     */\n    @Override\n    public String authorize(String state) {\n        return UrlBuilder.fromBaseUrl(source.authorize())\n            .queryParam(\"app_id\", config.getClientId())\n            .queryParam(\"scope\", \"auth_user\")\n            .queryParam(\"redirect_uri\", config.getRedirectUri())\n            .queryParam(\"state\", getRealState(state))\n            .build();\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthAlipayRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONObject;\nimport com.alipay.api.AlipayApiException;\nimport com.alipay.api.AlipayClient;\nimport com.alipay.api.DefaultAlipayClient;\nimport com.alipay.api.request.AlipaySystemOauthTokenRequest;\nimport com.alipay.api.request.AlipayUserInfoShareRequest;\nimport com.alipay.api.response.AlipaySystemOauthTokenResponse;\nimport com.alipay.api.response.AlipayUserInfoShareResponse;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.enums.AuthResponseStatus;\nimport me.zhyd.oauth.enums.AuthUserGender;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthResponse;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.AuthChecker;\nimport me.zhyd.oauth.utils.GlobalAuthUtils;\nimport me.zhyd.oauth.utils.StringUtils;\nimport me.zhyd.oauth.utils.UrlBuilder;\n\nimport java.net.InetSocketAddress;\n\n/**\n * 支付宝公钥模式登录\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.0.1\n */\npublic class AuthAlipayRequest extends AuthDefaultRequest {\n\n    /**\n     * 支付宝公钥：当选择支付宝登录时，该值可用\n     * 对应“RSA2(SHA256)密钥”中的“支付宝公钥”\n     */\n    private final String alipayPublicKey;\n\n    private final AlipayClient alipayClient;\n\n    private static final String GATEWAY = \"https://openapi.alipay.com/gateway.do\";\n\n    /**\n     * @see AuthAlipayRequest#AuthAlipayRequest(me.zhyd.oauth.config.AuthConfig, java.lang.String)\n     * @deprecated 请使用带有\"alipayPublicKey\"参数的构造方法\n     */\n    @Deprecated\n    public AuthAlipayRequest(AuthConfig config) {\n        this(config, (String) null);\n    }\n\n    /**\n     * @see AuthAlipayRequest#AuthAlipayRequest(me.zhyd.oauth.config.AuthConfig, java.lang.String, me.zhyd.oauth.cache.AuthStateCache)\n     * @deprecated 请使用带有\"alipayPublicKey\"参数的构造方法\n     */\n    @Deprecated\n    public AuthAlipayRequest(AuthConfig config, AuthStateCache authStateCache) {\n        this(config, null, authStateCache);\n    }\n\n    /**\n     * @see AuthAlipayRequest#AuthAlipayRequest(me.zhyd.oauth.config.AuthConfig, java.lang.String, me.zhyd.oauth.cache.AuthStateCache, java.lang.String, java.lang.Integer)\n     * @deprecated 请使用带有\"alipayPublicKey\"参数的构造方法\n     */\n    @Deprecated\n    public AuthAlipayRequest(AuthConfig config, AuthStateCache authStateCache, String proxyHost, Integer proxyPort) {\n        this(config, null, authStateCache, proxyHost, proxyPort);\n    }\n\n    /**\n     * 构造方法，需要设置\"alipayPublicKey\"\n     *\n     * @param config          公共的OAuth配置\n     * @param alipayPublicKey 支付宝公钥\n     * @see AuthAlipayRequest#AuthAlipayRequest(me.zhyd.oauth.config.AuthConfig)\n     */\n    public AuthAlipayRequest(AuthConfig config, String alipayPublicKey) {\n        super(config, AuthDefaultSource.ALIPAY);\n        this.alipayPublicKey = determineAlipayPublicKey(alipayPublicKey, config);\n        check(config);\n        this.alipayClient = new DefaultAlipayClient(GATEWAY, config.getClientId(), config.getClientSecret(), \"json\", \"UTF-8\", this.alipayPublicKey, \"RSA2\");\n    }\n\n    /**\n     * 构造方法，需要设置\"alipayPublicKey\"\n     *\n     * @param config          公共的OAuth配置\n     * @param alipayPublicKey 支付宝公钥\n     * @see AuthAlipayRequest#AuthAlipayRequest(me.zhyd.oauth.config.AuthConfig, me.zhyd.oauth.cache.AuthStateCache)\n     */\n    public AuthAlipayRequest(AuthConfig config, String alipayPublicKey, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.ALIPAY, authStateCache);\n        this.alipayPublicKey = determineAlipayPublicKey(alipayPublicKey, config);\n        check(config);\n        if (config.getHttpConfig() != null && config.getHttpConfig().getProxy() != null\n            && config.getHttpConfig().getProxy().address() instanceof InetSocketAddress) {\n            InetSocketAddress address = (InetSocketAddress) config.getHttpConfig().getProxy().address();\n            this.alipayClient = new DefaultAlipayClient(GATEWAY, config.getClientId(), config.getClientSecret(),\n                \"json\", \"UTF-8\", this.alipayPublicKey, \"RSA2\", address.getHostName(), address.getPort());\n        } else {\n            this.alipayClient = new DefaultAlipayClient(GATEWAY, config.getClientId(), config.getClientSecret(),\n                \"json\", \"UTF-8\", this.alipayPublicKey, \"RSA2\");\n        }\n    }\n\n    /**\n     * 构造方法，需要设置\"alipayPublicKey\"\n     *\n     * @param config          公共的OAuth配置\n     * @param alipayPublicKey 支付宝公钥\n     * @see AuthAlipayRequest#AuthAlipayRequest(me.zhyd.oauth.config.AuthConfig, me.zhyd.oauth.cache.AuthStateCache, java.lang.String, java.lang.Integer)\n     */\n    public AuthAlipayRequest(AuthConfig config, String alipayPublicKey, AuthStateCache authStateCache, String proxyHost, Integer proxyPort) {\n        super(config, AuthDefaultSource.ALIPAY, authStateCache);\n        this.alipayPublicKey = determineAlipayPublicKey(alipayPublicKey, config);\n        check(config);\n        this.alipayClient = new DefaultAlipayClient(GATEWAY, config.getClientId(), config.getClientSecret(),\n            \"json\", \"UTF-8\", this.alipayPublicKey, \"RSA2\", proxyHost, proxyPort);\n    }\n\n    private String determineAlipayPublicKey(String alipayPublicKey, AuthConfig config) {\n        return alipayPublicKey != null ? alipayPublicKey : config.getAlipayPublicKey();\n    }\n\n    protected void check(AuthConfig config) {\n        AuthChecker.checkConfig(config, AuthDefaultSource.ALIPAY);\n\n        if (!StringUtils.isNotEmpty(alipayPublicKey)) {\n            throw new AuthException(AuthResponseStatus.PARAMETER_INCOMPLETE, AuthDefaultSource.ALIPAY);\n        }\n\n        // 支付宝在创建回调地址时，不允许使用localhost或者127.0.0.1\n        if (GlobalAuthUtils.isLocalHost(config.getRedirectUri())) {\n            // The redirect uri of alipay is forbidden to use localhost or 127.0.0.1\n            throw new AuthException(AuthResponseStatus.ILLEGAL_REDIRECT_URI, AuthDefaultSource.ALIPAY);\n        }\n    }\n\n    @Override\n    protected void checkCode(AuthCallback authCallback) {\n        if (StringUtils.isEmpty(authCallback.getAuth_code())) {\n            throw new AuthException(AuthResponseStatus.ILLEGAL_CODE, source);\n        }\n    }\n\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        AlipaySystemOauthTokenRequest request = new AlipaySystemOauthTokenRequest();\n        request.setGrantType(\"authorization_code\");\n        request.setCode(authCallback.getAuth_code());\n        AlipaySystemOauthTokenResponse response;\n        try {\n            response = this.alipayClient.execute(request);\n        } catch (Exception e) {\n            throw new AuthException(e);\n        }\n        if (!response.isSuccess()) {\n            throw new AuthException(response.getSubMsg());\n        }\n        return AuthToken.builder()\n            .accessToken(response.getAccessToken())\n            .uid(response.getUserId())\n            .expireIn(Integer.parseInt(response.getExpiresIn()))\n            .refreshToken(response.getRefreshToken())\n            .build();\n    }\n\n    /**\n     * 刷新access token （续期）\n     *\n     * @param authToken 登录成功后返回的Token信息\n     * @return AuthResponse\n     */\n    @Override\n    public AuthResponse<AuthToken> refresh(AuthToken authToken) {\n        AlipaySystemOauthTokenRequest request = new AlipaySystemOauthTokenRequest();\n        request.setGrantType(\"refresh_token\");\n        request.setRefreshToken(authToken.getRefreshToken());\n        AlipaySystemOauthTokenResponse response = null;\n        try {\n            response = this.alipayClient.execute(request);\n        } catch (Exception e) {\n            throw new AuthException(e);\n        }\n        if (!response.isSuccess()) {\n            throw new AuthException(response.getSubMsg());\n        }\n        return AuthResponse.<AuthToken>builder()\n            .code(AuthResponseStatus.SUCCESS.getCode())\n            .data(AuthToken.builder()\n                .accessToken(response.getAccessToken())\n                .uid(response.getUserId())\n                .expireIn(Integer.parseInt(response.getExpiresIn()))\n                .refreshToken(response.getRefreshToken())\n                .build())\n            .build();\n    }\n\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        String accessToken = authToken.getAccessToken();\n        AlipayUserInfoShareRequest request = new AlipayUserInfoShareRequest();\n        AlipayUserInfoShareResponse response = null;\n        try {\n            response = this.alipayClient.execute(request, accessToken);\n        } catch (AlipayApiException e) {\n            throw new AuthException(e.getErrMsg(), e);\n        }\n        if (!response.isSuccess()) {\n            throw new AuthException(response.getSubMsg());\n        }\n\n        String province = response.getProvince(), city = response.getCity();\n        String location = String.format(\"%s %s\", StringUtils.isEmpty(province) ? \"\" : province, StringUtils.isEmpty(city) ? \"\" : city);\n\n        return AuthUser.builder()\n            .rawUserInfo(JSONObject.parseObject(JSONObject.toJSONString(response)))\n            .uuid(response.getUserId())\n            .username(StringUtils.isEmpty(response.getUserName()) ? response.getNickName() : response.getUserName())\n            .nickname(response.getNickName())\n            .avatar(response.getAvatar())\n            .location(location)\n            .gender(AuthUserGender.getRealGender(response.getGender()))\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n\n    /**\n     * 返回带{@code state}参数的授权url，授权回调时会带上这个{@code state}\n     *\n     * @param state state 验证授权流程的参数，可以防止csrf\n     * @return 返回授权地址\n     * @since 1.9.3\n     */\n    @Override\n    public String authorize(String state) {\n        return UrlBuilder.fromBaseUrl(source.authorize())\n            .queryParam(\"app_id\", config.getClientId())\n            .queryParam(\"scope\", \"auth_user\")\n            .queryParam(\"redirect_uri\", config.getRedirectUri())\n            .queryParam(\"state\", getRealState(state))\n            .build();\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthAliyunRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONObject;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.enums.AuthUserGender;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\n\n/**\n * 阿里云登录\n *\n * @author snippet0809 (https://github.com/snippet0809)\n * @since 1.15.5\n */\npublic class AuthAliyunRequest extends AuthDefaultRequest {\n\n    public AuthAliyunRequest(AuthConfig config) {\n        super(config, AuthDefaultSource.ALIYUN);\n    }\n\n    public AuthAliyunRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.ALIYUN, authStateCache);\n    }\n\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        String response = doPostAuthorizationCode(authCallback.getCode());\n        JSONObject accessTokenObject = JSONObject.parseObject(response);\n        return AuthToken.builder()\n            .accessToken(accessTokenObject.getString(\"access_token\"))\n            .expireIn(accessTokenObject.getIntValue(\"expires_in\"))\n            .tokenType(accessTokenObject.getString(\"token_type\"))\n            .idToken(accessTokenObject.getString(\"id_token\"))\n            .refreshToken(accessTokenObject.getString(\"refresh_token\"))\n            .build();\n    }\n\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        String userInfo = doGetUserInfo(authToken);\n        JSONObject object = JSONObject.parseObject(userInfo);\n        return AuthUser.builder()\n            .rawUserInfo(object)\n            .uuid(object.getString(\"sub\"))\n            .username(object.getString(\"login_name\"))\n            .nickname(object.getString(\"name\"))\n            .gender(AuthUserGender.UNKNOWN)\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthAmazonRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONObject;\nimport com.xkcoding.http.constants.Constants;\nimport com.xkcoding.http.support.HttpHeader;\nimport com.xkcoding.http.util.UrlUtil;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.enums.AuthResponseStatus;\nimport me.zhyd.oauth.enums.AuthUserGender;\nimport me.zhyd.oauth.enums.scope.AuthAmazonScope;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthResponse;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.AuthScopeUtils;\nimport me.zhyd.oauth.utils.HttpUtils;\nimport me.zhyd.oauth.utils.PkceUtil;\nimport me.zhyd.oauth.utils.UrlBuilder;\n\nimport java.util.HashMap;\nimport java.util.Map;\nimport java.util.concurrent.TimeUnit;\n\n/**\n * Amazon登录\n * Login with Amazon for Websites Overview： https://developer.amazon.com/zh/docs/login-with-amazon/register-web.html\n * Login with Amazon SDK for JavaScript Reference Guide：https://developer.amazon.com/zh/docs/login-with-amazon/javascript-sdk-reference.html\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.16.0\n */\npublic class AuthAmazonRequest extends AuthDefaultRequest {\n\n    public AuthAmazonRequest(AuthConfig config) {\n        super(config, AuthDefaultSource.AMAZON);\n    }\n\n    public AuthAmazonRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.AMAZON, authStateCache);\n    }\n\n    /**\n     * https://developer.amazon.com/zh/docs/login-with-amazon/authorization-code-grant.html#authorization-request\n     *\n     * @param state state 验证授权流程的参数，可以防止csrf\n     * @return String\n     */\n    @Override\n    public String authorize(String state) {\n        String realState = getRealState(state);\n        UrlBuilder builder = UrlBuilder.fromBaseUrl(source.authorize())\n            .queryParam(\"client_id\", config.getClientId())\n            .queryParam(\"scope\", this.getScopes(\" \", true, AuthScopeUtils.getDefaultScopes(AuthAmazonScope.values())))\n            .queryParam(\"redirect_uri\", config.getRedirectUri())\n            .queryParam(\"response_type\", \"code\")\n            .queryParam(\"state\", realState);\n\n        if (config.isPkce()) {\n            String cacheKey = this.source.getName().concat(\":code_verifier:\").concat(realState);\n            String codeVerifier = PkceUtil.generateCodeVerifier();\n            String codeChallengeMethod = \"S256\";\n            String codeChallenge = PkceUtil.generateCodeChallenge(codeChallengeMethod, codeVerifier);\n            builder.queryParam(\"code_challenge\", codeChallenge)\n                .queryParam(\"code_challenge_method\", codeChallengeMethod);\n            // 缓存 codeVerifier 十分钟\n            this.authStateCache.cache(cacheKey, codeVerifier, TimeUnit.MINUTES.toMillis(10));\n        }\n\n        return builder.build();\n    }\n\n    /**\n     * https://developer.amazon.com/zh/docs/login-with-amazon/authorization-code-grant.html#access-token-request\n     *\n     * @return access token\n     */\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        Map<String, String> form = new HashMap<>(9);\n        form.put(\"grant_type\", \"authorization_code\");\n        form.put(\"code\", authCallback.getCode());\n        form.put(\"redirect_uri\", config.getRedirectUri());\n        form.put(\"client_id\", config.getClientId());\n        form.put(\"client_secret\", config.getClientSecret());\n\n        if (config.isPkce()) {\n            String cacheKey = this.source.getName().concat(\":code_verifier:\").concat(authCallback.getState());\n            String codeVerifier = this.authStateCache.get(cacheKey);\n            form.put(\"code_verifier\", codeVerifier);\n        }\n        return getToken(form, this.source.accessToken());\n    }\n\n    @Override\n    public AuthResponse<AuthToken> refresh(AuthToken authToken) {\n        Map<String, String> form = new HashMap<>(7);\n        form.put(\"grant_type\", \"refresh_token\");\n        form.put(\"refresh_token\", authToken.getRefreshToken());\n        form.put(\"client_id\", config.getClientId());\n        form.put(\"client_secret\", config.getClientSecret());\n        return AuthResponse.<AuthToken>builder()\n            .code(AuthResponseStatus.SUCCESS.getCode())\n            .data(getToken(form, this.source.refresh()))\n            .build();\n\n    }\n\n    private AuthToken getToken(Map<String, String> param, String url) {\n        HttpHeader httpHeader = new HttpHeader();\n        httpHeader.add(\"Host\", \"api.amazon.com\");\n        httpHeader.add(Constants.CONTENT_TYPE, \"application/x-www-form-urlencoded;charset=UTF-8\");\n        String response = new HttpUtils(config.getHttpConfig()).post(url, param, httpHeader, false).getBody();\n        JSONObject jsonObject = JSONObject.parseObject(response);\n        this.checkResponse(jsonObject);\n        return AuthToken.builder()\n            .accessToken(jsonObject.getString(\"access_token\"))\n            .tokenType(jsonObject.getString(\"token_type\"))\n            .expireIn(jsonObject.getIntValue(\"expires_in\"))\n            .refreshToken(jsonObject.getString(\"refresh_token\"))\n            .build();\n    }\n\n    /**\n     * 校验响应内容是否正确\n     *\n     * @param jsonObject 响应内容\n     */\n    private void checkResponse(JSONObject jsonObject) {\n        if (jsonObject.containsKey(\"error\")) {\n            throw new AuthException(jsonObject.getString(\"error_description\").concat(\" \") + jsonObject.getString(\"error_description\"));\n        }\n    }\n\n    /**\n     * https://developer.amazon.com/zh/docs/login-with-amazon/obtain-customer-profile.html#call-profile-endpoint\n     *\n     * @param authToken token信息\n     * @return AuthUser\n     */\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        String accessToken = authToken.getAccessToken();\n        this.checkToken(accessToken);\n\n        HttpHeader httpHeader = new HttpHeader();\n        httpHeader.add(\"Host\", \"api.amazon.com\");\n        httpHeader.add(\"Authorization\", \"bearer \" + accessToken);\n        String userInfo = new HttpUtils(config.getHttpConfig()).get(this.source.userInfo(), new HashMap<>(0), httpHeader, false).getBody();\n        JSONObject jsonObject = JSONObject.parseObject(userInfo);\n        this.checkResponse(jsonObject);\n\n        return AuthUser.builder()\n            .rawUserInfo(jsonObject)\n            .uuid(jsonObject.getString(\"user_id\"))\n            .username(jsonObject.getString(\"name\"))\n            .nickname(jsonObject.getString(\"name\"))\n            .email(jsonObject.getString(\"email\"))\n            .gender(AuthUserGender.UNKNOWN)\n            .source(source.toString())\n            .token(authToken)\n            .build();\n    }\n\n    private void checkToken(String accessToken) {\n        String tokenInfo = new HttpUtils(config.getHttpConfig()).get(\"https://api.amazon.com/auth/o2/tokeninfo?access_token=\" + UrlUtil.urlEncode(accessToken)).getBody();\n        JSONObject jsonObject = JSONObject.parseObject(tokenInfo);\n        if (!config.getClientId().equals(jsonObject.getString(\"aud\"))) {\n            throw new AuthException(AuthResponseStatus.ILLEGAL_TOKEN);\n        }\n    }\n\n    @Override\n    protected String userInfoUrl(AuthToken authToken) {\n        return UrlBuilder.fromBaseUrl(source.userInfo())\n            .queryParam(\"user_id\", authToken.getUserId())\n            .queryParam(\"screen_name\", authToken.getScreenName())\n            .queryParam(\"include_entities\", true)\n            .build();\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthAppleRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONObject;\nimport io.jsonwebtoken.Jwts;\nimport io.jsonwebtoken.impl.security.AbstractJwk;\nimport lombok.Data;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.enums.AuthResponseStatus;\nimport me.zhyd.oauth.enums.scope.AuthAppleScope;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.AuthScopeUtils;\nimport me.zhyd.oauth.utils.StringUtils;\nimport me.zhyd.oauth.utils.UrlBuilder;\nimport org.bouncycastle.asn1.pkcs.PrivateKeyInfo;\nimport org.bouncycastle.openssl.PEMParser;\nimport org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter;\n\nimport java.io.IOException;\nimport java.io.StringReader;\nimport java.security.PrivateKey;\nimport java.util.Base64;\nimport java.util.Date;\nimport java.util.concurrent.TimeUnit;\n\npublic class AuthAppleRequest extends AuthDefaultRequest {\n\n    private static final String AUD = \"https://appleid.apple.com\";\n\n    private volatile PrivateKey privateKey;\n\n    public AuthAppleRequest(AuthConfig config) {\n        super(config, AuthDefaultSource.APPLE);\n    }\n\n    public AuthAppleRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.APPLE, authStateCache);\n    }\n\n    @Override\n    public String authorize(String state) {\n        return UrlBuilder.fromBaseUrl(super.authorize(state))\n            .queryParam(\"response_mode\", \"form_post\")\n            .queryParam(\"scope\", this.getScopes(\" \", false, AuthScopeUtils.getDefaultScopes(AuthAppleScope.values())))\n            .build();\n    }\n\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        if (!StringUtils.isEmpty(authCallback.getError())) {\n            throw new AuthException(authCallback.getError());\n        }\n        this.config.setClientSecret(this.getToken());\n        // if failed will throw AuthException\n        String response = doPostAuthorizationCode(authCallback.getCode());\n        JSONObject accessTokenObject = JSONObject.parseObject(response);\n        // https://developer.apple.com/documentation/sign_in_with_apple/tokenresponse\n        AuthToken.AuthTokenBuilder builder = AuthToken.builder()\n            .accessToken(accessTokenObject.getString(\"access_token\"))\n            .expireIn(accessTokenObject.getIntValue(\"expires_in\"))\n            .refreshToken(accessTokenObject.getString(\"refresh_token\"))\n            .tokenType(accessTokenObject.getString(\"token_type\"))\n            .idToken(accessTokenObject.getString(\"id_token\"));\n        if (!StringUtils.isEmpty(authCallback.getUser())) {\n            try {\n                AppleUserInfo userInfo = JSONObject.parseObject(authCallback.getUser(), AppleUserInfo.class);\n                builder.username(userInfo.getName().getFirstName() + \" \" + userInfo.getName().getLastName());\n            } catch (Exception ignored) {\n            }\n        }\n        return builder.build();\n    }\n\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        Base64.Decoder urlDecoder = Base64.getUrlDecoder();\n        String[] idToken = authToken.getIdToken().split(\"\\\\.\");\n        String payload = new String(urlDecoder.decode(idToken[1]));\n        JSONObject object = JSONObject.parseObject(payload);\n        // https://developer.apple.com/documentation/sign_in_with_apple/sign_in_with_apple_rest_api/authenticating_users_with_sign_in_with_apple#3383773\n        return AuthUser.builder()\n            .rawUserInfo(object)\n            .uuid(object.getString(\"sub\"))\n            .email(object.getString(\"email\"))\n            .username(authToken.getUsername())\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n\n    @Override\n    protected void checkConfig(AuthConfig config) {\n        super.checkConfig(config);\n        if (StringUtils.isEmpty(config.getClientId())) {\n            throw new AuthException(AuthResponseStatus.ILLEGAL_CLIENT_ID, source);\n        }\n        if (StringUtils.isEmpty(config.getClientSecret())) {\n            throw new AuthException(AuthResponseStatus.ILLEGAL_CLIENT_SECRET, source);\n        }\n        if (StringUtils.isEmpty(config.getKid())) {\n            throw new AuthException(AuthResponseStatus.ILLEGAL_KID, source);\n        }\n        if (StringUtils.isEmpty(config.getTeamId())) {\n            throw new AuthException(AuthResponseStatus.ILLEGAL_TEAM_ID, source);\n        }\n    }\n\n    /**\n     * 获取token\n     * @see <a href=\"https://developer.apple.com/documentation/accountorganizationaldatasharing/creating-a-client-secret\">creating-a-client-secret</a>\n     * @return jwt token\n     */\n    private String getToken() {\n        return Jwts.builder().header().add(AbstractJwk.KID.getId(), this.config.getKid()).and()\n            .issuer(this.config.getTeamId())\n            .subject(this.config.getClientId())\n            .audience().add(AUD).and()\n            .expiration(new Date(System.currentTimeMillis() + TimeUnit.MINUTES.toMillis(3)))\n            .issuedAt(new Date())\n            .signWith(getPrivateKey())\n            .compact();\n    }\n\n    private PrivateKey getPrivateKey() {\n        if (this.privateKey == null) {\n            synchronized (this) {\n                if (this.privateKey == null) {\n                    try (PEMParser pemParser = new PEMParser(new StringReader(this.config.getClientSecret()))) {\n                        JcaPEMKeyConverter pemKeyConverter = new JcaPEMKeyConverter();\n                        PrivateKeyInfo keyInfo = (PrivateKeyInfo) pemParser.readObject();\n                        this.privateKey = pemKeyConverter.getPrivateKey(keyInfo);\n                    } catch (IOException e) {\n                        throw new AuthException(\"Failed to get apple private key\", e);\n                    }\n                }\n            }\n        }\n        return this.privateKey;\n    }\n\n    @Data\n    static class AppleUserInfo {\n        private AppleUsername name;\n        private String email;\n    }\n\n    @Data\n    static class AppleUsername {\n        private String firstName;\n        private String lastName;\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthBaiduRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONObject;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.enums.AuthResponseStatus;\nimport me.zhyd.oauth.enums.AuthUserGender;\nimport me.zhyd.oauth.enums.scope.AuthBaiduScope;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthResponse;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.AuthScopeUtils;\nimport me.zhyd.oauth.utils.HttpUtils;\nimport me.zhyd.oauth.utils.StringUtils;\nimport me.zhyd.oauth.utils.UrlBuilder;\n\n/**\n * 百度账号登录\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.0.0\n */\npublic class AuthBaiduRequest extends AuthDefaultRequest {\n\n    public AuthBaiduRequest(AuthConfig config) {\n        super(config, AuthDefaultSource.BAIDU);\n    }\n\n    public AuthBaiduRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.BAIDU, authStateCache);\n    }\n\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        String response = doPostAuthorizationCode(authCallback.getCode());\n        return getAuthToken(response);\n    }\n\n    /**\n     * https://openapi.baidu.com/rest/2.0/passport/users/getInfo?access_token=121.c86e87cc0828cc1dabb8faee540531d4.YsUIAWvYbgqVni1VhkgKgyLh8nEyELbDOEZs_OA.OgDgmA\n     * https://openapi.baidu.com/rest/2.0/passport/users/getInfo?access_token=121.2907d9facf9fb97adf7287fa75496eda.Y3NSjR3-3HKt1RgT0HEl7GgxRXT5gOOVdngXezY.OcC_7g\n     * 新旧应用返回的用户信息不一致\n     *\n     * @param authToken token信息\n     * @return AuthUser\n     */\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        String userInfo = doGetUserInfo(authToken);\n        JSONObject object = JSONObject.parseObject(userInfo);\n        this.checkResponse(object);\n        return AuthUser.builder()\n            .rawUserInfo(object)\n            .uuid(object.containsKey(\"userid\") ? object.getString(\"userid\") : object.getString(\"openid\"))\n            .username(object.getString(\"username\"))\n            .nickname(object.getString(\"username\"))\n            .avatar(getAvatar(object))\n            .remark(object.getString(\"userdetail\"))\n            .gender(AuthUserGender.getRealGender(object.getString(\"sex\")))\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n\n    private String getAvatar(JSONObject object) {\n        String protrait = object.getString(\"portrait\");\n        return StringUtils.isEmpty(protrait) ? null : String.format(\"http://himg.bdimg.com/sys/portrait/item/%s.jpg\", protrait);\n    }\n\n    @Override\n    public AuthResponse revoke(AuthToken authToken) {\n        String response = doGetRevoke(authToken);\n        JSONObject object = JSONObject.parseObject(response);\n        this.checkResponse(object);\n        // 返回1表示取消授权成功，否则失败\n        AuthResponseStatus status = object.getIntValue(\"result\") == 1 ? AuthResponseStatus.SUCCESS : AuthResponseStatus.FAILURE;\n        return AuthResponse.builder().code(status.getCode()).msg(status.getMsg()).build();\n    }\n\n    @Override\n    public AuthResponse<AuthToken> refresh(AuthToken authToken) {\n        String refreshUrl = UrlBuilder.fromBaseUrl(this.source.refresh())\n            .queryParam(\"grant_type\", \"refresh_token\")\n            .queryParam(\"refresh_token\", authToken.getRefreshToken())\n            .queryParam(\"client_id\", this.config.getClientId())\n            .queryParam(\"client_secret\", this.config.getClientSecret())\n            .build();\n        String response = new HttpUtils(config.getHttpConfig()).get(refreshUrl).getBody();\n        return AuthResponse.<AuthToken>builder()\n            .code(AuthResponseStatus.SUCCESS.getCode())\n            .data(this.getAuthToken(response))\n            .build();\n    }\n\n    /**\n     * 返回带{@code state}参数的授权url，授权回调时会带上这个{@code state}\n     *\n     * @param state state 验证授权流程的参数，可以防止csrf\n     * @return 返回授权地址\n     * @since 1.9.3\n     */\n    @Override\n    public String authorize(String state) {\n        return UrlBuilder.fromBaseUrl(super.authorize(state))\n            .queryParam(\"display\", \"popup\")\n            .queryParam(\"scope\", this.getScopes(\" \", true, AuthScopeUtils.getDefaultScopes(AuthBaiduScope.values())))\n            .build();\n    }\n\n    /**\n     * 检查响应内容是否正确\n     *\n     * @param object 请求响应内容\n     */\n    private void checkResponse(JSONObject object) {\n        if (object.containsKey(\"error\") || object.containsKey(\"error_code\")) {\n            String msg = object.containsKey(\"error_description\") ? object.getString(\"error_description\") : object.getString(\"error_msg\");\n            throw new AuthException(msg);\n        }\n    }\n\n    private AuthToken getAuthToken(String response) {\n        JSONObject accessTokenObject = JSONObject.parseObject(response);\n        this.checkResponse(accessTokenObject);\n        return AuthToken.builder()\n            .accessToken(accessTokenObject.getString(\"access_token\"))\n            .refreshToken(accessTokenObject.getString(\"refresh_token\"))\n            .scope(accessTokenObject.getString(\"scope\"))\n            .expireIn(accessTokenObject.getIntValue(\"expires_in\"))\n            .build();\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthCodingRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONObject;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.enums.AuthUserGender;\nimport me.zhyd.oauth.enums.scope.AuthCodingScope;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.AuthScopeUtils;\nimport me.zhyd.oauth.utils.UrlBuilder;\n\n/**\n * Coding登录\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.0.0\n */\npublic class AuthCodingRequest extends AuthDefaultRequest {\n\n    public AuthCodingRequest(AuthConfig config) {\n        super(config, AuthDefaultSource.CODING);\n    }\n\n    public AuthCodingRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.CODING, authStateCache);\n    }\n\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        String response = doGetAuthorizationCode(authCallback.getCode());\n        JSONObject accessTokenObject = JSONObject.parseObject(response);\n        this.checkResponse(accessTokenObject);\n        return AuthToken.builder()\n            .accessToken(accessTokenObject.getString(\"access_token\"))\n            .expireIn(accessTokenObject.getIntValue(\"expires_in\"))\n            .refreshToken(accessTokenObject.getString(\"refresh_token\"))\n            .build();\n    }\n\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        String response = doGetUserInfo(authToken);\n        JSONObject object = JSONObject.parseObject(response);\n        this.checkResponse(object);\n\n        object = object.getJSONObject(\"data\");\n        return AuthUser.builder()\n            .rawUserInfo(object)\n            .uuid(object.getString(\"id\"))\n            .username(object.getString(\"name\"))\n            .avatar(\"https://coding.net\" + object.getString(\"avatar\"))\n            .blog(\"https://coding.net\" + object.getString(\"path\"))\n            .nickname(object.getString(\"name\"))\n            .company(object.getString(\"company\"))\n            .location(object.getString(\"location\"))\n            .gender(AuthUserGender.getRealGender(object.getString(\"sex\")))\n            .email(object.getString(\"email\"))\n            .remark(object.getString(\"slogan\"))\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n\n    /**\n     * 检查响应内容是否正确\n     *\n     * @param object 请求响应内容\n     */\n    private void checkResponse(JSONObject object) {\n        if (object.getIntValue(\"code\") != 0) {\n            throw new AuthException(object.getString(\"msg\"));\n        }\n    }\n\n    /**\n     * 返回带{@code state}参数的授权url，授权回调时会带上这个{@code state}\n     *\n     * @param state state 验证授权流程的参数，可以防止csrf\n     * @return 返回授权地址\n     * @since 1.9.3\n     */\n    @Override\n    public String authorize(String state) {\n        return UrlBuilder.fromBaseUrl(String.format(source.authorize(), config.getDomainPrefix()))\n            .queryParam(\"response_type\", \"code\")\n            .queryParam(\"client_id\", config.getClientId())\n            .queryParam(\"redirect_uri\", config.getRedirectUri())\n            .queryParam(\"scope\", this.getScopes(\" \", true, AuthScopeUtils.getDefaultScopes(AuthCodingScope.values())))\n            .queryParam(\"state\", getRealState(state))\n            .build();\n    }\n\n    /**\n     * 返回获取accessToken的url\n     *\n     * @param code 授权码\n     * @return 返回获取accessToken的url\n     */\n    @Override\n    public String accessTokenUrl(String code) {\n        return UrlBuilder.fromBaseUrl(String.format(source.accessToken(), config.getDomainPrefix()))\n            .queryParam(\"code\", code)\n            .queryParam(\"client_id\", config.getClientId())\n            .queryParam(\"client_secret\", config.getClientSecret())\n            .queryParam(\"grant_type\", \"authorization_code\")\n            .queryParam(\"redirect_uri\", config.getRedirectUri())\n            .build();\n    }\n\n    /**\n     * 返回获取userInfo的url\n     *\n     * @param authToken token\n     * @return 返回获取userInfo的url\n     */\n    @Override\n    public String userInfoUrl(AuthToken authToken) {\n        return UrlBuilder.fromBaseUrl(String.format(source.userInfo(), config.getDomainPrefix()))\n            .queryParam(\"access_token\", authToken.getAccessToken())\n            .build();\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONObject;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.enums.AuthUserGender;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\n\n/**\n * CSDN登录\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.0.0\n */\n@Deprecated\npublic class AuthCsdnRequest extends AuthDefaultRequest {\n\n    public AuthCsdnRequest(AuthConfig config) {\n        super(config, AuthDefaultSource.CSDN);\n    }\n\n    public AuthCsdnRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.CSDN, authStateCache);\n    }\n\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        String response = doPostAuthorizationCode(authCallback.getCode());\n        JSONObject accessTokenObject = JSONObject.parseObject(response);\n        this.checkResponse(accessTokenObject);\n        return AuthToken.builder().accessToken(accessTokenObject.getString(\"access_token\")).build();\n    }\n\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        String response = doGetUserInfo(authToken);\n        JSONObject object = JSONObject.parseObject(response);\n        this.checkResponse(object);\n        return AuthUser.builder()\n            .rawUserInfo(object)\n            .uuid(object.getString(\"username\"))\n            .username(object.getString(\"username\"))\n            .remark(object.getString(\"description\"))\n            .blog(object.getString(\"website\"))\n            .gender(AuthUserGender.UNKNOWN)\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n\n    /**\n     * 检查响应内容是否正确\n     *\n     * @param object 请求响应内容\n     */\n    private void checkResponse(JSONObject object) {\n        if (object.containsKey(\"error_code\")) {\n            throw new AuthException(object.getString(\"error\"));\n        }\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthDefaultRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.xkcoding.http.util.UrlUtil;\nimport me.zhyd.oauth.cache.AuthDefaultStateCache;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthSource;\nimport me.zhyd.oauth.enums.AuthResponseStatus;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.log.Log;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthResponse;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.*;\n\nimport java.util.List;\n\n/**\n * 默认的request处理类\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @author yangkai.shen (https://xkcoding.com)\n * @since 1.0.0\n */\npublic abstract class AuthDefaultRequest implements AuthRequest {\n    protected AuthConfig config;\n    protected AuthSource source;\n    protected AuthStateCache authStateCache;\n\n    public AuthDefaultRequest(AuthConfig config, AuthSource source) {\n        this(config, source, AuthDefaultStateCache.INSTANCE);\n    }\n\n    public AuthDefaultRequest(AuthConfig config, AuthSource source, AuthStateCache authStateCache) {\n        this.config = config;\n        this.source = source;\n        this.authStateCache = authStateCache;\n        if (!AuthChecker.isSupportedAuth(config, source)) {\n            throw new AuthException(AuthResponseStatus.PARAMETER_INCOMPLETE, source);\n        }\n        // 校验配置合法性\n        this.checkConfig(config);\n    }\n\n    /**\n     * 统一的登录入口。当通过{@link AuthDefaultRequest#authorize(String)}授权成功后，会跳转到调用方的相关回调方法中\n     * 方法的入参可以使用{@code AuthCallback}，{@code AuthCallback}类中封装好了OAuth2授权回调所需要的参数\n     *\n     * @param authCallback 用于接收回调参数的实体\n     * @return AuthResponse\n     */\n    @Override\n    public AuthResponse<AuthUser> login(AuthCallback authCallback) {\n        try {\n            checkCode(authCallback);\n            if (!config.isIgnoreCheckState()) {\n                AuthChecker.checkState(authCallback.getState(), source, authStateCache);\n            }\n\n            AuthToken authToken = this.getAccessToken(authCallback);\n            AuthUser user = this.getUserInfo(authToken);\n            return AuthResponse.<AuthUser>builder().code(AuthResponseStatus.SUCCESS.getCode()).data(user).build();\n        } catch (Exception e) {\n            Log.error(\"Failed to login with oauth authorization.\", e);\n            return this.responseError(e);\n        }\n    }\n\n    protected void checkCode(AuthCallback authCallback) {\n        AuthChecker.checkCode(source, authCallback);\n    }\n\n    /**\n     * 处理{@link AuthDefaultRequest#login(AuthCallback)} 发生异常的情况，统一响应参数\n     *\n     * @param e 具体的异常\n     * @return AuthResponse\n     */\n    AuthResponse<AuthUser> responseError(Exception e) {\n        int errorCode = AuthResponseStatus.FAILURE.getCode();\n        String errorMsg = e.getMessage();\n        if (e instanceof AuthException) {\n            AuthException authException = ((AuthException) e);\n            errorCode = authException.getErrorCode();\n            if (StringUtils.isNotEmpty(authException.getErrorMsg())) {\n                errorMsg = authException.getErrorMsg();\n            }\n        }\n        return AuthResponse.<AuthUser>builder().code(errorCode).msg(errorMsg).build();\n    }\n\n    /**\n     * 返回授权url，可自行跳转页面\n     * <p>\n     * 不建议使用该方式获取授权地址，不带{@code state}的授权地址，容易受到csrf攻击。\n     * 建议使用{@link AuthDefaultRequest#authorize(String)}方法生成授权地址，在回调方法中对{@code state}进行校验\n     *\n     * @return 返回授权地址\n     * @see AuthDefaultRequest#authorize(String)\n     */\n    @Deprecated\n    @Override\n    public String authorize() {\n        return this.authorize(null);\n    }\n\n    /**\n     * 返回带{@code state}参数的授权url，授权回调时会带上这个{@code state}\n     *\n     * @param state state 验证授权流程的参数，可以防止csrf\n     * @return 返回授权地址\n     * @since 1.9.3\n     */\n    @Override\n    public String authorize(String state) {\n        return UrlBuilder.fromBaseUrl(source.authorize())\n            .queryParam(\"response_type\", \"code\")\n            .queryParam(\"client_id\", config.getClientId())\n            .queryParam(\"redirect_uri\", config.getRedirectUri())\n            .queryParam(\"state\", getRealState(state))\n            .build();\n    }\n\n    /**\n     * 返回获取accessToken的url\n     *\n     * @param code 授权码\n     * @return 返回获取accessToken的url\n     */\n    protected String accessTokenUrl(String code) {\n        return UrlBuilder.fromBaseUrl(source.accessToken())\n            .queryParam(\"code\", code)\n            .queryParam(\"client_id\", config.getClientId())\n            .queryParam(\"client_secret\", config.getClientSecret())\n            .queryParam(\"grant_type\", \"authorization_code\")\n            .queryParam(\"redirect_uri\", config.getRedirectUri())\n            .build();\n    }\n\n    /**\n     * 返回获取accessToken的url\n     *\n     * @param refreshToken refreshToken\n     * @return 返回获取accessToken的url\n     */\n    protected String refreshTokenUrl(String refreshToken) {\n        return UrlBuilder.fromBaseUrl(source.refresh())\n            .queryParam(\"client_id\", config.getClientId())\n            .queryParam(\"client_secret\", config.getClientSecret())\n            .queryParam(\"refresh_token\", refreshToken)\n            .queryParam(\"grant_type\", \"refresh_token\")\n            .queryParam(\"redirect_uri\", config.getRedirectUri())\n            .build();\n    }\n\n    /**\n     * 返回获取userInfo的url\n     *\n     * @param authToken token\n     * @return 返回获取userInfo的url\n     */\n    protected String userInfoUrl(AuthToken authToken) {\n        return UrlBuilder.fromBaseUrl(source.userInfo()).queryParam(\"access_token\", authToken.getAccessToken()).build();\n    }\n\n    /**\n     * 返回获取revoke authorization的url\n     *\n     * @param authToken token\n     * @return 返回获取revoke authorization的url\n     */\n    protected String revokeUrl(AuthToken authToken) {\n        return UrlBuilder.fromBaseUrl(source.revoke()).queryParam(\"access_token\", authToken.getAccessToken()).build();\n    }\n\n    /**\n     * 获取state，如果为空， 则默认取当前日期的时间戳\n     *\n     * @param state 原始的state\n     * @return 返回不为null的state\n     */\n    protected String getRealState(String state) {\n        if (StringUtils.isEmpty(state)) {\n            state = UuidUtils.getUUID();\n        }\n        // 缓存state\n        authStateCache.cache(state, state);\n        return state;\n    }\n\n    /**\n     * 通用的 authorizationCode 协议\n     *\n     * @param code code码\n     * @return Response\n     */\n    protected String doPostAuthorizationCode(String code) {\n        return new HttpUtils(config.getHttpConfig()).post(accessTokenUrl(code)).getBody();\n    }\n\n    /**\n     * 通用的 authorizationCode 协议\n     *\n     * @param code code码\n     * @return Response\n     */\n    protected String doGetAuthorizationCode(String code) {\n        return new HttpUtils(config.getHttpConfig()).get(accessTokenUrl(code)).getBody();\n    }\n\n    /**\n     * 通用的 用户信息\n     *\n     * @param authToken token封装\n     * @return Response\n     */\n    @Deprecated\n    protected String doPostUserInfo(AuthToken authToken) {\n        return new HttpUtils(config.getHttpConfig()).post(userInfoUrl(authToken)).getBody();\n    }\n\n    /**\n     * 通用的 用户信息\n     *\n     * @param authToken token封装\n     * @return Response\n     */\n    protected String doGetUserInfo(AuthToken authToken) {\n        return new HttpUtils(config.getHttpConfig()).get(userInfoUrl(authToken)).getBody();\n    }\n\n    /**\n     * 通用的post形式的取消授权方法\n     *\n     * @param authToken token封装\n     * @return Response\n     */\n    @Deprecated\n    protected String doPostRevoke(AuthToken authToken) {\n        return new HttpUtils(config.getHttpConfig()).post(revokeUrl(authToken)).getBody();\n    }\n\n    /**\n     * 通用的post形式的取消授权方法\n     *\n     * @param authToken token封装\n     * @return Response\n     */\n    protected String doGetRevoke(AuthToken authToken) {\n        return new HttpUtils(config.getHttpConfig()).get(revokeUrl(authToken)).getBody();\n    }\n\n    /**\n     * 获取以 {@code separator}分割过后的 scope 信息\n     *\n     * @param separator     多个 {@code scope} 间的分隔符\n     * @param encode        是否 encode 编码\n     * @param defaultScopes 默认的 scope， 当客户端没有配置 {@code scopes} 时启用\n     * @return String\n     * @since 1.16.7\n     */\n    protected String getScopes(String separator, boolean encode, List<String> defaultScopes) {\n        List<String> scopes = config.getScopes();\n        if (null == scopes || scopes.isEmpty()) {\n            if (null == defaultScopes || defaultScopes.isEmpty()) {\n                return \"\";\n            }\n            scopes = defaultScopes;\n        }\n        if (null == separator) {\n            // 默认为空格\n            separator = \" \";\n        }\n        String scopeStr = String.join(separator, scopes);\n        return encode ? UrlUtil.urlEncode(scopeStr) : scopeStr;\n    }\n\n    protected void checkConfig(AuthConfig config) {\n        AuthChecker.checkConfig(config, source);\n    }\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthDingTalkAccountRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\n\n/**\n * 钉钉账号登录\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.0.0\n */\npublic class AuthDingTalkAccountRequest extends AbstractAuthDingtalkRequest {\n\n    public AuthDingTalkAccountRequest(AuthConfig config) {\n        super(config, AuthDefaultSource.DINGTALK_ACCOUNT);\n    }\n\n    public AuthDingTalkAccountRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.DINGTALK_ACCOUNT, authStateCache);\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthDingTalkRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\n\n/**\n * 钉钉二维码登录\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.0.0\n */\npublic class AuthDingTalkRequest extends AbstractAuthDingtalkRequest {\n\n    public AuthDingTalkRequest(AuthConfig config) {\n        super(config, AuthDefaultSource.DINGTALK);\n    }\n\n    public AuthDingTalkRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.DINGTALK, authStateCache);\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthDingTalkV2Request.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONObject;\nimport com.xkcoding.http.support.HttpHeader;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.enums.scope.AuthDingTalkScope;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.AuthScopeUtils;\nimport me.zhyd.oauth.utils.HttpUtils;\nimport me.zhyd.oauth.utils.UrlBuilder;\n\nimport java.util.HashMap;\nimport java.util.Map;\n\n/**\n * 新版钉钉二维码登录\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.16.7\n */\npublic class AuthDingTalkV2Request extends AuthDefaultRequest {\n\n    public AuthDingTalkV2Request(AuthConfig config) {\n        super(config, AuthDefaultSource.DINGTALK_V2);\n    }\n\n    public AuthDingTalkV2Request(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.DINGTALK_V2, authStateCache);\n    }\n\n    @Override\n    public String authorize(String state) {\n        return UrlBuilder.fromBaseUrl(source.authorize())\n            .queryParam(\"response_type\", \"code\")\n            .queryParam(\"client_id\", config.getClientId())\n            .queryParam(\"scope\", this.getScopes(\",\", true, AuthScopeUtils.getDefaultScopes(AuthDingTalkScope.values())))\n            .queryParam(\"redirect_uri\", config.getRedirectUri())\n            .queryParam(\"prompt\", \"consent\")\n            .queryParam(\"org_type\", config.getDingTalkOrgType())\n            .queryParam(\"corpId\", config.getDingTalkCorpId())\n            .queryParam(\"exclusiveLogin\", config.isDingTalkExclusiveLogin())\n            .queryParam(\"exclusiveCorpId\", config.getDingTalkExclusiveCorpId())\n            .queryParam(\"state\", getRealState(state))\n            .build();\n    }\n\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        Map<String, String> params = new HashMap<>();\n        params.put(\"grantType\", \"authorization_code\");\n        params.put(\"clientId\", config.getClientId());\n        params.put(\"clientSecret\", config.getClientSecret());\n        params.put(\"code\", authCallback.getCode());\n        String response = new HttpUtils(config.getHttpConfig()).post(this.source.accessToken(), JSONObject.toJSONString(params)).getBody();\n        JSONObject accessTokenObject = JSONObject.parseObject(response);\n        if (!accessTokenObject.containsKey(\"accessToken\")) {\n            throw new AuthException(JSONObject.toJSONString(response), source);\n        }\n        return AuthToken.builder()\n            .accessToken(accessTokenObject.getString(\"accessToken\"))\n            .refreshToken(accessTokenObject.getString(\"refreshToken\"))\n            .expireIn(accessTokenObject.getIntValue(\"expireIn\"))\n            .corpId(accessTokenObject.getString(\"corpId\"))\n            .build();\n    }\n\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        HttpHeader header = new HttpHeader();\n        header.add(\"x-acs-dingtalk-access-token\", authToken.getAccessToken());\n\n        String response = new HttpUtils(config.getHttpConfig()).get(this.source.userInfo(), null, header, false).getBody();\n        JSONObject object = JSONObject.parseObject(response);\n\n        authToken.setOpenId(object.getString(\"openId\"));\n        authToken.setUnionId(object.getString(\"unionId\"));\n        return AuthUser.builder()\n            .rawUserInfo(object)\n            .uuid(object.getString(\"unionId\"))\n            .username(object.getString(\"nick\"))\n            .nickname(object.getString(\"nick\"))\n            .avatar(object.getString(\"avatarUrl\"))\n            .snapshotUser(object.getBooleanValue(\"visitor\"))\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n\n    /**\n     * 返回获取accessToken的url\n     *\n     * @param code 授权码\n     * @return 返回获取accessToken的url\n     */\n    protected String accessTokenUrl(String code) {\n        return UrlBuilder.fromBaseUrl(source.accessToken())\n            .queryParam(\"code\", code)\n            .queryParam(\"clientId\", config.getClientId())\n            .queryParam(\"clientSecret\", config.getClientSecret())\n            .queryParam(\"grantType\", \"authorization_code\")\n            .build();\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthDouyinRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONObject;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.enums.AuthResponseStatus;\nimport me.zhyd.oauth.enums.AuthUserGender;\nimport me.zhyd.oauth.enums.scope.AuthDouyinScope;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthResponse;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.AuthScopeUtils;\nimport me.zhyd.oauth.utils.HttpUtils;\nimport me.zhyd.oauth.utils.UrlBuilder;\n\n\n/**\n * 抖音登录\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.4.0\n */\npublic class AuthDouyinRequest extends AuthDefaultRequest {\n\n    public AuthDouyinRequest(AuthConfig config) {\n        super(config, AuthDefaultSource.DOUYIN);\n    }\n\n    public AuthDouyinRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.DOUYIN, authStateCache);\n    }\n\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        return this.getToken(accessTokenUrl(authCallback.getCode()));\n    }\n\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        String response = doGetUserInfo(authToken);\n        JSONObject userInfoObject = JSONObject.parseObject(response);\n        this.checkResponse(userInfoObject);\n        JSONObject object = userInfoObject.getJSONObject(\"data\");\n        authToken.setUnionId(object.getString(\"union_id\"));\n        return AuthUser.builder()\n            .rawUserInfo(object)\n            .uuid(object.getString(\"union_id\"))\n            .username(object.getString(\"nickname\"))\n            .nickname(object.getString(\"nickname\"))\n            .avatar(object.getString(\"avatar\"))\n            .remark(object.getString(\"description\"))\n            .gender(AuthUserGender.getRealGender(object.getString(\"gender\")))\n            .location(String.format(\"%s %s %s\", object.getString(\"country\"), object.getString(\"province\"), object.getString(\"city\")))\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n\n    @Override\n    public AuthResponse<AuthToken> refresh(AuthToken oldToken) {\n        return AuthResponse.<AuthToken>builder()\n            .code(AuthResponseStatus.SUCCESS.getCode())\n            .data(getToken(refreshTokenUrl(oldToken.getRefreshToken())))\n            .build();\n    }\n\n    /**\n     * 检查响应内容是否正确\n     *\n     * @param object 请求响应内容\n     */\n    private void checkResponse(JSONObject object) {\n        String message = object.getString(\"message\");\n        JSONObject data = object.getJSONObject(\"data\");\n        int errorCode = data.getIntValue(\"error_code\");\n        if (\"error\".equals(message) || errorCode != 0) {\n            throw new AuthException(errorCode, data.getString(\"description\"));\n        }\n    }\n\n    /**\n     * 获取token，适用于获取access_token和刷新token\n     *\n     * @param accessTokenUrl 实际请求token的地址\n     * @return token对象\n     */\n    private AuthToken getToken(String accessTokenUrl) {\n        String response = new HttpUtils(config.getHttpConfig()).post(accessTokenUrl).getBody();\n        JSONObject object = JSONObject.parseObject(response);\n        this.checkResponse(object);\n        JSONObject dataObj = object.getJSONObject(\"data\");\n        return AuthToken.builder()\n            .accessToken(dataObj.getString(\"access_token\"))\n            .openId(dataObj.getString(\"open_id\"))\n            .expireIn(dataObj.getIntValue(\"expires_in\"))\n            .refreshToken(dataObj.getString(\"refresh_token\"))\n            .refreshTokenExpireIn(dataObj.getIntValue(\"refresh_expires_in\"))\n            .scope(dataObj.getString(\"scope\"))\n            .build();\n    }\n\n    /**\n     * 返回带{@code state}参数的授权url，授权回调时会带上这个{@code state}\n     *\n     * @param state state 验证授权流程的参数，可以防止csrf\n     * @return 返回授权地址\n     * @since 1.9.3\n     */\n    @Override\n    public String authorize(String state) {\n        return UrlBuilder.fromBaseUrl(source.authorize())\n            .queryParam(\"response_type\", \"code\")\n            .queryParam(\"client_key\", config.getClientId())\n            .queryParam(\"redirect_uri\", config.getRedirectUri())\n            .queryParam(\"scope\", this.getScopes(\",\", true, AuthScopeUtils.getDefaultScopes(AuthDouyinScope.values())))\n            .queryParam(\"state\", getRealState(state))\n            .build();\n    }\n\n    /**\n     * 返回获取accessToken的url\n     *\n     * @param code oauth的授权码\n     * @return 返回获取accessToken的url\n     */\n    @Override\n    protected String accessTokenUrl(String code) {\n        return UrlBuilder.fromBaseUrl(source.accessToken())\n            .queryParam(\"code\", code)\n            .queryParam(\"client_key\", config.getClientId())\n            .queryParam(\"client_secret\", config.getClientSecret())\n            .queryParam(\"grant_type\", \"authorization_code\")\n            .build();\n    }\n\n    /**\n     * 返回获取userInfo的url\n     *\n     * @param authToken oauth返回的token\n     * @return 返回获取userInfo的url\n     */\n    @Override\n    protected String userInfoUrl(AuthToken authToken) {\n        return UrlBuilder.fromBaseUrl(source.userInfo())\n            .queryParam(\"access_token\", authToken.getAccessToken())\n            .queryParam(\"open_id\", authToken.getOpenId())\n            .build();\n    }\n\n    /**\n     * 返回获取accessToken的url\n     *\n     * @param refreshToken oauth返回的refreshtoken\n     * @return 返回获取accessToken的url\n     */\n    @Override\n    protected String refreshTokenUrl(String refreshToken) {\n        return UrlBuilder.fromBaseUrl(source.refresh())\n            .queryParam(\"client_key\", config.getClientId())\n            .queryParam(\"refresh_token\", refreshToken)\n            .queryParam(\"grant_type\", \"refresh_token\")\n            .build();\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthElemeRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONObject;\nimport me.zhyd.oauth.utils.HttpUtils;\nimport com.xkcoding.http.constants.Constants;\nimport com.xkcoding.http.support.HttpHeader;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.enums.AuthResponseStatus;\nimport me.zhyd.oauth.enums.AuthUserGender;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthResponse;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.Base64Utils;\nimport me.zhyd.oauth.utils.GlobalAuthUtils;\nimport me.zhyd.oauth.utils.UrlBuilder;\nimport me.zhyd.oauth.utils.UuidUtils;\n\nimport java.util.HashMap;\nimport java.util.Map;\n\n/**\n * 饿了么\n * <p>\n * 注：集成的是正式环境，非沙箱环境\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.12.0\n */\npublic class AuthElemeRequest extends AuthDefaultRequest {\n\n    private static final String CONTENT_TYPE_FORM = \"application/x-www-form-urlencoded;charset=UTF-8\";\n    private static final String CONTENT_TYPE_JSON = \"application/json; charset=utf-8\";\n\n    public AuthElemeRequest(AuthConfig config) {\n        super(config, AuthDefaultSource.ELEME);\n    }\n\n    public AuthElemeRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.ELEME, authStateCache);\n    }\n\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        Map<String, String> form = new HashMap<>(7);\n        form.put(\"client_id\", config.getClientId());\n        form.put(\"redirect_uri\", config.getRedirectUri());\n        form.put(\"code\", authCallback.getCode());\n        form.put(\"grant_type\", \"authorization_code\");\n\n        HttpHeader httpHeader = this.buildHeader(CONTENT_TYPE_FORM, this.getRequestId(), true);\n        String response = new HttpUtils(config.getHttpConfig()).post(source.accessToken(), form, httpHeader, false).getBody();\n        JSONObject object = JSONObject.parseObject(response);\n\n        this.checkResponse(object);\n\n        return AuthToken.builder()\n            .accessToken(object.getString(\"access_token\"))\n            .refreshToken(object.getString(\"refresh_token\"))\n            .tokenType(object.getString(\"token_type\"))\n            .expireIn(object.getIntValue(\"expires_in\"))\n            .build();\n    }\n\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        Map<String, Object> parameters = new HashMap<>(4);\n        // 获取商户账号信息的API接口名称\n        String action = \"eleme.user.getUser\";\n        // 时间戳，单位秒。API服务端允许客户端请求最大时间误差为正负5分钟。\n        final long timestamp = System.currentTimeMillis();\n        // 公共参数\n        Map<String, Object> metasHashMap = new HashMap<>(4);\n        metasHashMap.put(\"app_key\", config.getClientId());\n        metasHashMap.put(\"timestamp\", timestamp);\n        String signature = GlobalAuthUtils.generateElemeSignature(config.getClientId(), config.getClientSecret(), timestamp, action, authToken\n            .getAccessToken(), parameters);\n\n        String requestId = this.getRequestId();\n\n        Map<String, Object> paramsMap = new HashMap<>();\n        paramsMap.put(\"nop\", \"1.0.0\");\n        paramsMap.put(\"id\", requestId);\n        paramsMap.put(\"action\", action);\n        paramsMap.put(\"token\", authToken.getAccessToken());\n        paramsMap.put(\"metas\", metasHashMap);\n        paramsMap.put(\"params\", parameters);\n        paramsMap.put(\"signature\", signature);\n\n        HttpHeader httpHeader = this.buildHeader(CONTENT_TYPE_JSON, requestId, false);\n        String response = new HttpUtils(config.getHttpConfig()).post(source.userInfo(), JSONObject.toJSONString(paramsMap), httpHeader).getBody();\n\n        JSONObject object = JSONObject.parseObject(response);\n\n        // 校验请求\n        if (object.containsKey(\"name\")) {\n            throw new AuthException(object.getString(\"message\"));\n        }\n        if (object.containsKey(\"error\") && null != object.get(\"error\")) {\n            throw new AuthException(object.getJSONObject(\"error\").getString(\"message\"));\n        }\n\n        JSONObject result = object.getJSONObject(\"result\");\n\n        return AuthUser.builder()\n            .rawUserInfo(result)\n            .uuid(result.getString(\"userId\"))\n            .username(result.getString(\"userName\"))\n            .nickname(result.getString(\"userName\"))\n            .gender(AuthUserGender.UNKNOWN)\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n\n    @Override\n    public AuthResponse<AuthToken> refresh(AuthToken oldToken) {\n        Map<String, String> form = new HashMap<>(4);\n        form.put(\"refresh_token\", oldToken.getRefreshToken());\n        form.put(\"grant_type\", \"refresh_token\");\n\n        HttpHeader httpHeader = this.buildHeader(CONTENT_TYPE_FORM, this.getRequestId(), true);\n        String response = new HttpUtils(config.getHttpConfig()).post(source.refresh(), form, httpHeader, false).getBody();\n\n        JSONObject object = JSONObject.parseObject(response);\n\n        this.checkResponse(object);\n\n        return AuthResponse.<AuthToken>builder()\n            .code(AuthResponseStatus.SUCCESS.getCode())\n            .data(AuthToken.builder()\n                .accessToken(object.getString(\"access_token\"))\n                .refreshToken(object.getString(\"refresh_token\"))\n                .tokenType(object.getString(\"token_type\"))\n                .expireIn(object.getIntValue(\"expires_in\"))\n                .build())\n            .build();\n    }\n\n    @Override\n    public String authorize(String state) {\n        return UrlBuilder.fromBaseUrl(super.authorize(state)).queryParam(\"scope\", \"all\").build();\n    }\n\n    private String getBasic(String appKey, String appSecret) {\n        StringBuilder sb = new StringBuilder();\n        String encodeToString = Base64Utils.encode((appKey + \":\" + appSecret).getBytes());\n        sb.append(\"Basic\").append(\" \").append(encodeToString);\n        return sb.toString();\n    }\n\n    private HttpHeader buildHeader(String contentType, String requestId, boolean auth) {\n        HttpHeader httpHeader = new HttpHeader();\n        httpHeader.add(\"Accept\", \"text/xml,text/javascript,text/html\");\n        httpHeader.add(Constants.CONTENT_TYPE, contentType);\n        httpHeader.add(\"Accept-Encoding\", \"gzip\");\n        httpHeader.add(\"User-Agent\", \"eleme-openapi-java-sdk\");\n        httpHeader.add(\"x-eleme-requestid\", requestId);\n        if (auth) {\n            httpHeader.add(\"Authorization\", this.getBasic(config.getClientId(), config.getClientSecret()));\n        }\n        return httpHeader;\n    }\n\n    private String getRequestId() {\n        return (UuidUtils.getUUID() + \"|\" + System.currentTimeMillis()).toUpperCase();\n    }\n\n    private void checkResponse(JSONObject object) {\n        if (object.containsKey(\"error\")) {\n            throw new AuthException(object.getString(\"error_description\"));\n        }\n    }\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthFacebookRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONObject;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.enums.AuthResponseStatus;\nimport me.zhyd.oauth.enums.AuthUserGender;\nimport me.zhyd.oauth.enums.scope.AuthFacebookScope;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.AuthScopeUtils;\nimport me.zhyd.oauth.utils.GlobalAuthUtils;\nimport me.zhyd.oauth.utils.UrlBuilder;\n\n/**\n * Facebook登录\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.3.0\n */\npublic class AuthFacebookRequest extends AuthDefaultRequest {\n\n    public AuthFacebookRequest(AuthConfig config) {\n        super(config, AuthDefaultSource.FACEBOOK);\n    }\n\n    public AuthFacebookRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.FACEBOOK, authStateCache);\n    }\n\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        String response = doPostAuthorizationCode(authCallback.getCode());\n        JSONObject accessTokenObject = JSONObject.parseObject(response);\n        this.checkResponse(accessTokenObject);\n        return AuthToken.builder()\n            .accessToken(accessTokenObject.getString(\"access_token\"))\n            .expireIn(accessTokenObject.getIntValue(\"expires_in\"))\n            .tokenType(accessTokenObject.getString(\"token_type\"))\n            .build();\n    }\n\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        String userInfo = doGetUserInfo(authToken);\n        JSONObject object = JSONObject.parseObject(userInfo);\n        this.checkResponse(object);\n        return AuthUser.builder()\n            .rawUserInfo(object)\n            .uuid(object.getString(\"id\"))\n            .username(object.getString(\"name\"))\n            .nickname(object.getString(\"name\"))\n            .blog(object.getString(\"link\"))\n            .avatar(getUserPicture(object))\n            .location(object.getString(\"locale\"))\n            .email(object.getString(\"email\"))\n            .gender(AuthUserGender.getRealGender(object.getString(\"gender\")))\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n\n    private String getUserPicture(JSONObject object) {\n        String picture = null;\n        if (object.containsKey(\"picture\")) {\n            JSONObject pictureObj = object.getJSONObject(\"picture\");\n            pictureObj = pictureObj.getJSONObject(\"data\");\n            if (null != pictureObj) {\n                picture = pictureObj.getString(\"url\");\n            }\n        }\n        return picture;\n    }\n\n    /**\n     * 返回获取userInfo的url\n     *\n     * @param authToken 用户token\n     * @return 返回获取userInfo的url\n     */\n    @Override\n    protected String userInfoUrl(AuthToken authToken) {\n        return UrlBuilder.fromBaseUrl(source.userInfo())\n            .queryParam(\"access_token\", authToken.getAccessToken())\n            .queryParam(\"fields\", \"id,name,birthday,gender,hometown,email,devices,picture.width(400),link\")\n            .build();\n    }\n\n    @Override\n    protected void checkConfig(AuthConfig config) {\n        super.checkConfig(config);\n        // facebook的回调地址必须为https的链接\n        if (AuthDefaultSource.FACEBOOK == source && !GlobalAuthUtils.isHttpsProtocol(config.getRedirectUri())) {\n            // Facebook's redirect uri must use the HTTPS protocol\n            throw new AuthException(AuthResponseStatus.ILLEGAL_REDIRECT_URI, source);\n        }\n    }\n\n    /**\n     * 检查响应内容是否正确\n     *\n     * @param object 请求响应内容\n     */\n    private void checkResponse(JSONObject object) {\n        if (object.containsKey(\"error\")) {\n            throw new AuthException(object.getJSONObject(\"error\").getString(\"message\"));\n        }\n    }\n\n    /**\n     * 返回带{@code state}参数的授权url，授权回调时会带上这个{@code state}\n     *\n     * @param state state 验证授权流程的参数，可以防止csrf\n     * @return 返回授权地址\n     */\n    @Override\n    public String authorize(String state) {\n        return UrlBuilder.fromBaseUrl(super.authorize(state))\n            .queryParam(\"scope\", this.getScopes(\",\", false, AuthScopeUtils.getDefaultScopes(AuthFacebookScope.values())))\n            .build();\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthFeishuRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSON;\nimport com.alibaba.fastjson.JSONObject;\nimport com.xkcoding.http.support.HttpHeader;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.enums.AuthResponseStatus;\nimport me.zhyd.oauth.enums.AuthUserGender;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthResponse;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.GlobalAuthUtils;\nimport me.zhyd.oauth.utils.HttpUtils;\nimport me.zhyd.oauth.utils.StringUtils;\nimport me.zhyd.oauth.utils.UrlBuilder;\n\n/**\n * 飞书平台，企业自建应用授权登录，原逻辑由 beacon 集成于 1.14.0 版，但最新的飞书 api 已修改，并且飞书平台一直为 {@code Deprecated} 状态\n * <p>\n * 所以，最终修改该平台的实际发布版本为 1.15.9\n *\n * @author beacon\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com) 重构业务逻辑 20210101\n * @since 1.15.9\n */\npublic class AuthFeishuRequest extends AuthDefaultRequest {\n\n    public AuthFeishuRequest(AuthConfig config) {\n        super(config, AuthDefaultSource.FEISHU);\n    }\n\n    public AuthFeishuRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.FEISHU, authStateCache);\n    }\n\n    /**\n     * 获取 app_access_token（企业自建应用）\n     * <p>\n     * Token 有效期为 2 小时，在此期间调用该接口 token 不会改变。当 token 有效期小于 30 分的时候，再次请求获取 token 的时候，\n     * 会生成一个新的 token，与此同时老的 token 依然有效。\n     *\n     * @return appAccessToken\n     */\n    private String getAppAccessToken() {\n        String cacheKey = this.source.getName().concat(\":app_access_token:\").concat(config.getClientId());\n        String cacheAppAccessToken = this.authStateCache.get(cacheKey);\n        if (StringUtils.isNotEmpty(cacheAppAccessToken)) {\n            return cacheAppAccessToken;\n        }\n        String url = \"https://open.feishu.cn/open-apis/auth/v3/app_access_token/internal/\";\n        JSONObject requestObject = new JSONObject();\n        requestObject.put(\"app_id\", config.getClientId());\n        requestObject.put(\"app_secret\", config.getClientSecret());\n        String response = new HttpUtils(config.getHttpConfig()).post(url, requestObject.toJSONString(), new HttpHeader()\n            .add(\"Content-Type\", \"application/json\")).getBody();\n        JSONObject jsonObject = JSON.parseObject(response);\n        this.checkResponse(jsonObject);\n        String appAccessToken = jsonObject.getString(\"app_access_token\");\n        // 缓存 app access token\n        this.authStateCache.cache(cacheKey, appAccessToken, jsonObject.getLongValue(\"expire\") * 1000);\n        return appAccessToken;\n    }\n\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        JSONObject requestObject = new JSONObject();\n        requestObject.put(\"app_access_token\", this.getAppAccessToken());\n        requestObject.put(\"grant_type\", \"authorization_code\");\n        requestObject.put(\"code\", authCallback.getCode());\n        return getToken(requestObject, this.source.accessToken());\n\n    }\n\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        String accessToken = authToken.getAccessToken();\n        String response = new HttpUtils(config.getHttpConfig()).get(source.userInfo(), null, new HttpHeader()\n            .add(\"Content-Type\", \"application/json\")\n            .add(\"Authorization\", \"Bearer \" + accessToken), false).getBody();\n        JSONObject object = JSON.parseObject(response);\n        this.checkResponse(object);\n        JSONObject data = object.getJSONObject(\"data\");\n        return AuthUser.builder()\n            .rawUserInfo(object)\n            .uuid(data.getString(\"union_id\"))\n            .username(data.getString(\"name\"))\n            .nickname(data.getString(\"name\"))\n            .avatar(data.getString(\"avatar_url\"))\n            .email(data.getString(\"email\"))\n            .gender(AuthUserGender.UNKNOWN)\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n\n    @Override\n    public AuthResponse<AuthToken> refresh(AuthToken authToken) {\n        JSONObject requestObject = new JSONObject();\n        requestObject.put(\"app_access_token\", this.getAppAccessToken());\n        requestObject.put(\"grant_type\", \"refresh_token\");\n        requestObject.put(\"refresh_token\", authToken.getRefreshToken());\n        return AuthResponse.<AuthToken>builder()\n            .code(AuthResponseStatus.SUCCESS.getCode())\n            .data(getToken(requestObject, this.source.refresh()))\n            .build();\n\n    }\n\n    private AuthToken getToken(JSONObject param, String url) {\n        String response = new HttpUtils(config.getHttpConfig()).post(url, param.toJSONString(), new HttpHeader()\n            .add(\"Content-Type\", \"application/json\")).getBody();\n        JSONObject jsonObject = JSON.parseObject(response);\n        this.checkResponse(jsonObject);\n        JSONObject data = jsonObject.getJSONObject(\"data\");\n        return AuthToken.builder()\n            .accessToken(data.getString(\"access_token\"))\n            .refreshToken(data.getString(\"refresh_token\"))\n            .expireIn(data.getIntValue(\"expires_in\"))\n            .tokenType(data.getString(\"token_type\"))\n            .openId(data.getString(\"open_id\"))\n            .build();\n    }\n\n    @Override\n    public String authorize(String state) {\n        return UrlBuilder.fromBaseUrl(source.authorize())\n            .queryParam(\"app_id\", config.getClientId())\n            .queryParam(\"redirect_uri\", GlobalAuthUtils.urlEncode(config.getRedirectUri()))\n            .queryParam(\"state\", getRealState(state))\n            .build();\n    }\n\n\n    /**\n     * 校验响应内容是否正确\n     *\n     * @param jsonObject 响应内容\n     */\n    private void checkResponse(JSONObject jsonObject) {\n        if (jsonObject.getIntValue(\"code\") != 0) {\n            throw new AuthException(jsonObject.getString(\"message\"));\n        }\n    }\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthFigmaRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONObject;\nimport com.xkcoding.http.support.HttpHeader;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.enums.AuthResponseStatus;\nimport me.zhyd.oauth.enums.scope.AuthFigmaScope;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthResponse;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.*;\n\n/**\n * Figma登录\n * @author xiangqian\n * @since 1.16.6\n */\npublic class AuthFigmaRequest extends AuthDefaultRequest {\n    public AuthFigmaRequest(AuthConfig config) {\n        super(config, AuthDefaultSource.FIGMA);\n    }\n\n    public AuthFigmaRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.FIGMA, authStateCache);\n    }\n\n    @Override\n    public String authorize(String state) {\n        return UrlBuilder.fromBaseUrl(super.authorize(state))\n            .queryParam(\"scope\", this.getScopes(\",\", true, AuthScopeUtils.getDefaultScopes(AuthFigmaScope.values())))\n            .build();\n    }\n\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        HttpHeader header = new HttpHeader()\n            .add(\"content-type\", \"application/x-www-form-urlencoded\")\n            .add(\"Authorization\", \"Basic \" + Base64Utils.encode(config.getClientId().concat(\":\").concat(config.getClientSecret())));\n\n        String response = new HttpUtils(config.getHttpConfig()).post(super.accessTokenUrl(authCallback.getCode()), null, header, true).getBody();\n        JSONObject accessTokenObject = JSONObject.parseObject(response);\n\n        this.checkResponse(accessTokenObject);\n\n        return AuthToken.builder()\n            .accessToken(accessTokenObject.getString(\"access_token\"))\n            .refreshToken(accessTokenObject.getString(\"refresh_token\"))\n            .scope(accessTokenObject.getString(\"scope\"))\n            .userId(accessTokenObject.getString(\"user_id\"))\n            .expireIn(accessTokenObject.getIntValue(\"expires_in\"))\n            .build();\n    }\n\n    @Override\n    public AuthResponse<AuthToken> refresh(AuthToken authToken) {\n        HttpHeader header = new HttpHeader().add(\"content-type\", \"application/x-www-form-urlencoded\");\n        String response = new HttpUtils(config.getHttpConfig()).post(this.refreshTokenUrl(authToken.getRefreshToken()), null, header, false).getBody();\n        JSONObject dataObj = JSONObject.parseObject(response);\n\n        this.checkResponse(dataObj);\n\n        return AuthResponse.<AuthToken>builder()\n            .code(AuthResponseStatus.SUCCESS.getCode())\n            .data(AuthToken.builder()\n                .accessToken(dataObj.getString(\"access_token\"))\n                .openId(dataObj.getString(\"open_id\"))\n                .expireIn(dataObj.getIntValue(\"expires_in\"))\n                .refreshToken(dataObj.getString(\"refresh_token\"))\n                .scope(dataObj.getString(\"scope\"))\n                .build())\n            .build();\n\n    }\n\n    @Override\n    protected String refreshTokenUrl(String refreshToken) {\n        return UrlBuilder.fromBaseUrl(source.refresh())\n            .queryParam(\"client_id\", config.getClientId())\n            .queryParam(\"client_secret\", config.getClientSecret())\n            .queryParam(\"refresh_token\", refreshToken)\n            .build();\n    }\n\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        HttpHeader header = new HttpHeader().add(\"Authorization\", \"Bearer \" + authToken.getAccessToken());\n        String response = new HttpUtils(config.getHttpConfig()).get(super.userInfoUrl(authToken), null, header, false).getBody();\n        JSONObject dataObj = JSONObject.parseObject(response);\n\n        this.checkResponse(dataObj);\n\n        return AuthUser.builder()\n            .rawUserInfo(dataObj)\n            .uuid(dataObj.getString(\"id\"))\n            .username(dataObj.getString(\"handle\"))\n            .avatar(dataObj.getString(\"img_url\"))\n            .email(dataObj.getString(\"email\"))\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n\n\n    /**\n     * 校验响应结果\n     *\n     * @param object 接口返回的结果\n     */\n    private void checkResponse(JSONObject object) {\n        if (object.containsKey(\"error\")) {\n            throw new AuthException(object.getString(\"error\") + \":\" + object.getString(\"message\"));\n        }\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthGiteeRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONObject;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.enums.AuthUserGender;\nimport me.zhyd.oauth.enums.scope.AuthGiteeScope;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.AuthScopeUtils;\nimport me.zhyd.oauth.utils.UrlBuilder;\n\n/**\n * Gitee登录\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.0.0\n */\npublic class AuthGiteeRequest extends AuthDefaultRequest {\n\n    public AuthGiteeRequest(AuthConfig config) {\n        super(config, AuthDefaultSource.GITEE);\n    }\n\n    public AuthGiteeRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.GITEE, authStateCache);\n    }\n\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        String response = doPostAuthorizationCode(authCallback.getCode());\n        JSONObject accessTokenObject = JSONObject.parseObject(response);\n        this.checkResponse(accessTokenObject);\n        return AuthToken.builder()\n            .accessToken(accessTokenObject.getString(\"access_token\"))\n            .refreshToken(accessTokenObject.getString(\"refresh_token\"))\n            .scope(accessTokenObject.getString(\"scope\"))\n            .tokenType(accessTokenObject.getString(\"token_type\"))\n            .expireIn(accessTokenObject.getIntValue(\"expires_in\"))\n            .build();\n    }\n\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        String userInfo = doGetUserInfo(authToken);\n        JSONObject object = JSONObject.parseObject(userInfo);\n        this.checkResponse(object);\n        return AuthUser.builder()\n            .rawUserInfo(object)\n            .uuid(object.getString(\"id\"))\n            .username(object.getString(\"login\"))\n            .avatar(object.getString(\"avatar_url\"))\n            .blog(object.getString(\"blog\"))\n            .nickname(object.getString(\"name\"))\n            .company(object.getString(\"company\"))\n            .location(object.getString(\"address\"))\n            .email(object.getString(\"email\"))\n            .remark(object.getString(\"bio\"))\n            .gender(AuthUserGender.UNKNOWN)\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n\n    /**\n     * 检查响应内容是否正确\n     *\n     * @param object 请求响应内容\n     */\n    private void checkResponse(JSONObject object) {\n        if (object.containsKey(\"error\")) {\n            throw new AuthException(object.getString(\"error_description\"));\n        }\n    }\n\n    /**\n     * 返回带{@code state}参数的授权url，授权回调时会带上这个{@code state}\n     *\n     * @param state state 验证授权流程的参数，可以防止csrf\n     * @return 返回授权地址\n     */\n    @Override\n    public String authorize(String state) {\n        return UrlBuilder.fromBaseUrl(super.authorize(state))\n            .queryParam(\"scope\", this.getScopes(\" \", true, AuthScopeUtils.getDefaultScopes(AuthGiteeScope.values())))\n            .build();\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthGithubRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONObject;\nimport com.xkcoding.http.support.HttpHeader;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.enums.AuthUserGender;\nimport me.zhyd.oauth.enums.scope.AuthGithubScope;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.AuthScopeUtils;\nimport me.zhyd.oauth.utils.GlobalAuthUtils;\nimport me.zhyd.oauth.utils.HttpUtils;\nimport me.zhyd.oauth.utils.UrlBuilder;\n\nimport java.util.Map;\n\n/**\n * Github登录\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.0.0\n */\npublic class AuthGithubRequest extends AuthDefaultRequest {\n\n    public AuthGithubRequest(AuthConfig config) {\n        super(config, AuthDefaultSource.GITHUB);\n    }\n\n    public AuthGithubRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.GITHUB, authStateCache);\n    }\n\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        String response = doPostAuthorizationCode(authCallback.getCode());\n        Map<String, String> res = GlobalAuthUtils.parseStringToMap(response);\n\n        this.checkResponse(res.containsKey(\"error\"), res.get(\"error_description\"));\n\n        return AuthToken.builder()\n            .accessToken(res.get(\"access_token\"))\n            .scope(res.get(\"scope\"))\n            .tokenType(res.get(\"token_type\"))\n            .build();\n    }\n\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        HttpHeader header = new HttpHeader();\n        header.add(\"Authorization\", \"token \" + authToken.getAccessToken());\n        String response = new HttpUtils(config.getHttpConfig()).get(UrlBuilder.fromBaseUrl(source.userInfo()).build(), null, header, false).getBody();\n        JSONObject object = JSONObject.parseObject(response);\n\n        this.checkResponse(object.containsKey(\"error\"), object.getString(\"error_description\"));\n\n        return AuthUser.builder()\n            .rawUserInfo(object)\n            .uuid(object.getString(\"id\"))\n            .username(object.getString(\"login\"))\n            .avatar(object.getString(\"avatar_url\"))\n            .blog(object.getString(\"blog\"))\n            .nickname(object.getString(\"name\"))\n            .company(object.getString(\"company\"))\n            .location(object.getString(\"location\"))\n            .email(object.getString(\"email\"))\n            .remark(object.getString(\"bio\"))\n            .gender(AuthUserGender.UNKNOWN)\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n\n    private void checkResponse(boolean error, String errorDescription) {\n        if (error) {\n            throw new AuthException(errorDescription);\n        }\n    }\n\n    /**\n     * 返回带{@code state}参数的授权url，授权回调时会带上这个{@code state}\n     *\n     * @param state state 验证授权流程的参数，可以防止csrf\n     * @return 返回授权地址\n     */\n    @Override\n    public String authorize(String state) {\n        return UrlBuilder.fromBaseUrl(super.authorize(state))\n            .queryParam(\"scope\", this.getScopes(\" \", true, AuthScopeUtils.getDefaultScopes(AuthGithubScope.values())))\n            .build();\n    }\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthGitlabRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONObject;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.enums.AuthUserGender;\nimport me.zhyd.oauth.enums.scope.AuthGitlabScope;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.AuthScopeUtils;\nimport me.zhyd.oauth.utils.UrlBuilder;\n\n/**\n * Gitlab登录\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.11.0\n */\npublic class AuthGitlabRequest extends AuthDefaultRequest {\n\n    public AuthGitlabRequest(AuthConfig config) {\n        super(config, AuthDefaultSource.GITLAB);\n    }\n\n    public AuthGitlabRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.GITLAB, authStateCache);\n    }\n\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        String response = doPostAuthorizationCode(authCallback.getCode());\n        JSONObject object = JSONObject.parseObject(response);\n\n        this.checkResponse(object);\n\n        return AuthToken.builder()\n            .accessToken(object.getString(\"access_token\"))\n            .refreshToken(object.getString(\"refresh_token\"))\n            .idToken(object.getString(\"id_token\"))\n            .tokenType(object.getString(\"token_type\"))\n            .scope(object.getString(\"scope\"))\n            .build();\n    }\n\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        String response = doGetUserInfo(authToken);\n        JSONObject object = JSONObject.parseObject(response);\n\n        this.checkResponse(object);\n\n        return AuthUser.builder()\n            .rawUserInfo(object)\n            .uuid(object.getString(\"id\"))\n            .username(object.getString(\"username\"))\n            .nickname(object.getString(\"name\"))\n            .avatar(object.getString(\"avatar_url\"))\n            .blog(object.getString(\"web_url\"))\n            .company(object.getString(\"organization\"))\n            .location(object.getString(\"location\"))\n            .email(object.getString(\"email\"))\n            .remark(object.getString(\"bio\"))\n            .gender(AuthUserGender.UNKNOWN)\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n\n    private void checkResponse(JSONObject object) {\n        // oauth/token 验证异常\n        if (object.containsKey(\"error\")) {\n            throw new AuthException(object.getString(\"error_description\"));\n        }\n        // user 验证异常\n        if (object.containsKey(\"message\")) {\n            throw new AuthException(object.getString(\"message\"));\n        }\n    }\n\n    /**\n     * 返回带{@code state}参数的授权url，授权回调时会带上这个{@code state}\n     *\n     * @param state state 验证授权流程的参数，可以防止csrf\n     * @return 返回授权地址\n     * @since 1.11.0\n     */\n    @Override\n    public String authorize(String state) {\n        return UrlBuilder.fromBaseUrl(super.authorize(state))\n            .queryParam(\"scope\", this.getScopes(\"+\", false, AuthScopeUtils.getDefaultScopes(AuthGitlabScope.values())))\n            .build();\n    }\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthGoogleRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONObject;\nimport me.zhyd.oauth.utils.HttpUtils;\nimport com.xkcoding.http.support.HttpHeader;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.enums.AuthUserGender;\nimport me.zhyd.oauth.enums.scope.AuthGoogleScope;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.AuthScopeUtils;\nimport me.zhyd.oauth.utils.HttpUtils;\nimport me.zhyd.oauth.utils.UrlBuilder;\n\n/**\n * Google登录\n *\n * @author yangkai.shen (https://xkcoding.com)\n * @since 1.3.0\n */\npublic class AuthGoogleRequest extends AuthDefaultRequest {\n\n    public AuthGoogleRequest(AuthConfig config) {\n        super(config, AuthDefaultSource.GOOGLE);\n    }\n\n    public AuthGoogleRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.GOOGLE, authStateCache);\n    }\n\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        String response = doPostAuthorizationCode(authCallback.getCode());\n        JSONObject accessTokenObject = JSONObject.parseObject(response);\n        this.checkResponse(accessTokenObject);\n        return AuthToken.builder()\n            .accessToken(accessTokenObject.getString(\"access_token\"))\n            .expireIn(accessTokenObject.getIntValue(\"expires_in\"))\n            .scope(accessTokenObject.getString(\"scope\"))\n            .tokenType(accessTokenObject.getString(\"token_type\"))\n            .idToken(accessTokenObject.getString(\"id_token\"))\n            .build();\n    }\n\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        HttpHeader httpHeader = new HttpHeader();\n        httpHeader.add(\"Authorization\", \"Bearer \" + authToken.getAccessToken());\n        String userInfo = new HttpUtils(config.getHttpConfig()).post(userInfoUrl(authToken), null, httpHeader).getBody();\n        JSONObject object = JSONObject.parseObject(userInfo);\n        this.checkResponse(object);\n        return AuthUser.builder()\n            .rawUserInfo(object)\n            .uuid(object.getString(\"sub\"))\n            .username(object.getString(\"email\"))\n            .avatar(object.getString(\"picture\"))\n            .nickname(object.getString(\"name\"))\n            .location(object.getString(\"locale\"))\n            .email(object.getString(\"email\"))\n            .gender(AuthUserGender.UNKNOWN)\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n\n    /**\n     * 返回带{@code state}参数的授权url，授权回调时会带上这个{@code state}\n     *\n     * @param state state 验证授权流程的参数，可以防止csrf\n     * @return 返回授权地址\n     * @since 1.9.3\n     */\n    @Override\n    public String authorize(String state) {\n        return UrlBuilder.fromBaseUrl(super.authorize(state))\n            .queryParam(\"access_type\", \"offline\")\n            .queryParam(\"scope\", this.getScopes(\" \", false, AuthScopeUtils.getDefaultScopes(AuthGoogleScope.values())))\n            .queryParam(\"prompt\",\"select_account\")\n            .build();\n    }\n\n    /**\n     * 返回获取userInfo的url\n     *\n     * @param authToken 用户授权后的token\n     * @return 返回获取userInfo的url\n     */\n    @Override\n    protected String userInfoUrl(AuthToken authToken) {\n        return UrlBuilder.fromBaseUrl(source.userInfo()).queryParam(\"access_token\", authToken.getAccessToken()).build();\n    }\n\n    /**\n     * 检查响应内容是否正确\n     *\n     * @param object 请求响应内容\n     */\n    private void checkResponse(JSONObject object) {\n        if (object.containsKey(\"error\") || object.containsKey(\"error_description\")) {\n            throw new AuthException(object.containsKey(\"error\") + \":\" + object.getString(\"error_description\"));\n        }\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthHuaweiRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONObject;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.enums.AuthUserGender;\nimport me.zhyd.oauth.enums.scope.AuthHuaweiScope;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthResponse;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.AuthScopeUtils;\nimport me.zhyd.oauth.utils.HttpUtils;\nimport me.zhyd.oauth.utils.UrlBuilder;\n\nimport java.util.HashMap;\nimport java.util.Map;\n\nimport static me.zhyd.oauth.enums.AuthResponseStatus.SUCCESS;\n\n/**\n * 华为授权登录\n *\n * 当前方式未来可能被废弃，建议使用 {@link AuthHuaweiV3Request}\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @version 1.0\n * @since 1.10.0\n */\n@Deprecated\npublic class AuthHuaweiRequest extends AuthDefaultRequest {\n\n    public AuthHuaweiRequest(AuthConfig config) {\n        super(config, AuthDefaultSource.HUAWEI);\n    }\n\n    public AuthHuaweiRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.HUAWEI, authStateCache);\n    }\n\n    /**\n     * 获取access token\n     *\n     * @param authCallback 授权成功后的回调参数\n     * @return token\n     * @see AuthDefaultRequest#authorize()\n     * @see AuthDefaultRequest#authorize(String)\n     */\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        Map<String, String> form = new HashMap<>(8);\n        form.put(\"grant_type\", \"authorization_code\");\n        form.put(\"code\", authCallback.getAuthorization_code());\n        form.put(\"client_id\", config.getClientId());\n        form.put(\"client_secret\", config.getClientSecret());\n        form.put(\"redirect_uri\", config.getRedirectUri());\n\n        String response = new HttpUtils(config.getHttpConfig()).post(source.accessToken(), form, false).getBody();\n        return getAuthToken(response);\n    }\n\n    /**\n     * 使用token换取用户信息\n     *\n     * @param authToken token信息\n     * @return 用户信息\n     * @see AuthDefaultRequest#getAccessToken(AuthCallback)\n     */\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        Map<String, String> form = new HashMap<>(7);\n        form.put(\"nsp_ts\", System.currentTimeMillis() + \"\");\n        form.put(\"access_token\", authToken.getAccessToken());\n        form.put(\"nsp_fmt\", \"JS\");\n        form.put(\"open_id\", \"OPENID\");\n        // form.put(\"nsp_svc\", \"OpenUP.User.getInfo\");\n        form.put(\"nsp_svc\", \"huawei.oauth2.user.getTokenInfo\");\n\n        String response = new HttpUtils(config.getHttpConfig()).post(source.userInfo(), form, false).getBody();\n        JSONObject object = JSONObject.parseObject(response);\n\n        this.checkResponse(object);\n\n        AuthUserGender gender = getRealGender(object);\n\n        return AuthUser.builder()\n            .rawUserInfo(object)\n            .uuid(object.getString(\"userID\"))\n            .username(object.getString(\"userName\"))\n            .nickname(object.getString(\"userName\"))\n            .gender(gender)\n            .avatar(object.getString(\"headPictureURL\"))\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n\n    /**\n     * 刷新access token （续期）\n     *\n     * @param authToken 登录成功后返回的Token信息\n     * @return AuthResponse\n     */\n    @Override\n    public AuthResponse<AuthToken> refresh(AuthToken authToken) {\n        Map<String, String> form = new HashMap<>(7);\n        form.put(\"client_id\", config.getClientId());\n        form.put(\"client_secret\", config.getClientSecret());\n        form.put(\"refresh_token\", authToken.getRefreshToken());\n        form.put(\"grant_type\", \"refresh_token\");\n\n        String response = new HttpUtils(config.getHttpConfig()).post(source.refresh(), form, false).getBody();\n        return AuthResponse.<AuthToken>builder().code(SUCCESS.getCode()).data(getAuthToken(response)).build();\n    }\n\n    private AuthToken getAuthToken(String response) {\n        JSONObject object = JSONObject.parseObject(response);\n\n        this.checkResponse(object);\n\n        return AuthToken.builder()\n            .accessToken(object.getString(\"access_token\"))\n            .expireIn(object.getIntValue(\"expires_in\"))\n            .refreshToken(object.getString(\"refresh_token\"))\n            .build();\n    }\n\n    /**\n     * 返回带{@code state}参数的授权url，授权回调时会带上这个{@code state}\n     *\n     * @param state state 验证授权流程的参数，可以防止csrf\n     * @return 返回授权地址\n     * @since 1.9.3\n     */\n    @Override\n    public String authorize(String state) {\n        return UrlBuilder.fromBaseUrl(super.authorize(state))\n            .queryParam(\"access_type\", \"offline\")\n            .queryParam(\"scope\", this.getScopes(\" \", true, AuthScopeUtils.getDefaultScopes(AuthHuaweiScope.values())))\n            .build();\n    }\n\n    /**\n     * 返回获取userInfo的url\n     *\n     * @param authToken token\n     * @return 返回获取userInfo的url\n     */\n    @Override\n    protected String userInfoUrl(AuthToken authToken) {\n        return UrlBuilder.fromBaseUrl(source.userInfo())\n            .queryParam(\"nsp_ts\", System.currentTimeMillis())\n            .queryParam(\"access_token\", authToken.getAccessToken())\n            .queryParam(\"nsp_fmt\", \"JS\")\n            .queryParam(\"nsp_svc\", \"OpenUP.User.getInfo\")\n            .build();\n    }\n\n    /**\n     * 获取用户的实际性别。华为系统中，用户的性别：1表示女，0表示男\n     *\n     * @param object obj\n     * @return AuthUserGender\n     */\n    private AuthUserGender getRealGender(JSONObject object) {\n        int genderCodeInt = object.getIntValue(\"gender\");\n        String genderCode = genderCodeInt == 1 ? \"0\" : (genderCodeInt == 0) ? \"1\" : genderCodeInt + \"\";\n        return AuthUserGender.getRealGender(genderCode);\n    }\n\n    /**\n     * 校验响应结果\n     *\n     * @param object 接口返回的结果\n     */\n    private void checkResponse(JSONObject object) {\n        if (object.containsKey(\"NSP_STATUS\")) {\n            throw new AuthException(object.getString(\"error\"));\n        }\n        if (object.containsKey(\"error\")) {\n            throw new AuthException(object.getString(\"sub_error\") + \":\" + object.getString(\"error_description\"));\n        }\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthHuaweiV3Request.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONObject;\nimport com.xkcoding.http.constants.Constants;\nimport com.xkcoding.http.support.HttpHeader;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.enums.AuthUserGender;\nimport me.zhyd.oauth.enums.scope.AuthHuaweiV3Scope;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthResponse;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.*;\n\nimport java.nio.charset.StandardCharsets;\nimport java.util.Base64;\nimport java.util.HashMap;\nimport java.util.Map;\nimport java.util.concurrent.TimeUnit;\n\nimport static me.zhyd.oauth.enums.AuthResponseStatus.SUCCESS;\n\n/**\n * 华为授权登录\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @version 1.0\n * @since 1.16.7\n */\npublic class AuthHuaweiV3Request extends AuthDefaultRequest {\n\n    public AuthHuaweiV3Request(AuthConfig config) {\n        super(config, AuthDefaultSource.HUAWEI_V3);\n    }\n\n    public AuthHuaweiV3Request(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.HUAWEI_V3, authStateCache);\n    }\n\n    /**\n     * 获取access token\n     *\n     * @param authCallback 授权成功后的回调参数\n     * @return token\n     * @see AuthDefaultRequest#authorize()\n     * @see AuthDefaultRequest#authorize(String)\n     */\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        Map<String, String> form = new HashMap<>(8);\n        form.put(\"grant_type\", \"authorization_code\");\n        form.put(\"code\", authCallback.getCode());\n        form.put(\"client_id\", config.getClientId());\n        form.put(\"client_secret\", config.getClientSecret());\n        form.put(\"redirect_uri\", config.getRedirectUri());\n\n        if (config.isPkce()) {\n            String cacheKey = this.source.getName().concat(\":code_verifier:\").concat(authCallback.getState());\n            String codeVerifier = this.authStateCache.get(cacheKey);\n            form.put(\"code_verifier\", codeVerifier);\n        }\n\n        HttpHeader httpHeader = new HttpHeader();\n        httpHeader.add(Constants.CONTENT_TYPE, \"application/x-www-form-urlencoded\");\n        String response = new HttpUtils(config.getHttpConfig()).post(source.accessToken(), form, httpHeader, false).getBody();\n        return getAuthToken(response);\n    }\n\n    /**\n     * 使用token换取用户信息\n     *\n     * @param authToken token信息\n     * @return 用户信息\n     * @see AuthDefaultRequest#getAccessToken(AuthCallback)\n     */\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        String idToken = authToken.getIdToken();\n        if (StringUtils.isEmpty(idToken)) {\n            Map<String, String> form = new HashMap<>(7);\n            form.put(\"access_token\", authToken.getAccessToken());\n            form.put(\"getNickName\", \"1\");\n            form.put(\"nsp_svc\", \"GOpen.User.getInfo\");\n\n            HttpHeader httpHeader = new HttpHeader();\n            httpHeader.add(Constants.CONTENT_TYPE, \"application/x-www-form-urlencoded\");\n            String response = new HttpUtils(config.getHttpConfig()).post(source.userInfo(), form, httpHeader, false).getBody();\n            JSONObject object = JSONObject.parseObject(response);\n\n            this.checkResponse(object);\n\n            return AuthUser.builder()\n                .rawUserInfo(object)\n                .uuid(object.getString(\"unionID\"))\n                .username(object.getString(\"displayName\"))\n                .nickname(object.getString(\"displayName\"))\n                .gender(AuthUserGender.UNKNOWN)\n                .avatar(object.getString(\"headPictureURL\"))\n                .token(authToken)\n                .source(source.toString())\n                .build();\n        }\n        String payload = new String(Base64.getUrlDecoder().decode(idToken.split(\"\\\\.\")[1]), StandardCharsets.UTF_8);\n\n        JSONObject object = JSONObject.parseObject(payload);\n        return AuthUser.builder()\n            .rawUserInfo(object)\n            .uuid(object.getString(\"sub\"))\n            .username(object.getString(\"name\"))\n            .nickname(object.getString(\"nickname\"))\n            .gender(AuthUserGender.UNKNOWN)\n            .avatar(object.getString(\"picture\"))\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n\n    /**\n     * 刷新access token （续期）\n     *\n     * @param authToken 登录成功后返回的Token信息\n     * @return AuthResponse\n     */\n    @Override\n    public AuthResponse<AuthToken> refresh(AuthToken authToken) {\n        Map<String, String> form = new HashMap<>(7);\n        form.put(\"client_id\", config.getClientId());\n        form.put(\"client_secret\", config.getClientSecret());\n        form.put(\"refresh_token\", authToken.getRefreshToken());\n        form.put(\"grant_type\", \"refresh_token\");\n\n        HttpHeader httpHeader = new HttpHeader();\n        httpHeader.add(Constants.CONTENT_TYPE, \"application/x-www-form-urlencoded\");\n        String response = new HttpUtils(config.getHttpConfig()).post(source.refresh(), form, httpHeader, false).getBody();\n        return AuthResponse.<AuthToken>builder().code(SUCCESS.getCode()).data(getAuthToken(response)).build();\n    }\n\n    private AuthToken getAuthToken(String response) {\n        JSONObject object = JSONObject.parseObject(response);\n\n        this.checkResponse(object);\n\n        return AuthToken.builder()\n            .accessToken(object.getString(\"access_token\"))\n            .expireIn(object.getIntValue(\"expires_in\"))\n            .refreshToken(object.getString(\"refresh_token\"))\n            .idToken(object.getString(\"id_token\"))\n            .build();\n    }\n\n    /**\n     * 返回带{@code state}参数的授权url，授权回调时会带上这个{@code state}\n     *\n     * @param state state 验证授权流程的参数，可以防止csrf\n     * @return 返回授权地址\n     * @since 1.9.3\n     */\n    @Override\n    public String authorize(String state) {\n        String realState = getRealState(state);\n        UrlBuilder builder = UrlBuilder.fromBaseUrl(super.authorize(realState))\n            .queryParam(\"access_type\", \"offline\")\n            .queryParam(\"scope\", this.getScopes(\" \", true, AuthScopeUtils.getDefaultScopes(AuthHuaweiV3Scope.values())));\n\n        if (config.isPkce()) {\n            String cacheKey = this.source.getName().concat(\":code_verifier:\").concat(realState);\n            String codeVerifier = PkceUtil.generateCodeVerifier();\n            String codeChallengeMethod = \"S256\";\n            String codeChallenge = PkceUtil.generateCodeChallenge(codeChallengeMethod, codeVerifier);\n            builder.queryParam(\"code_challenge\", codeChallenge)\n                .queryParam(\"code_challenge_method\", codeChallengeMethod);\n            // 缓存 codeVerifier 十分钟\n            this.authStateCache.cache(cacheKey, codeVerifier, TimeUnit.MINUTES.toMillis(10));\n        }\n        return builder.build();\n    }\n\n    /**\n     * 校验响应结果\n     *\n     * @param object 接口返回的结果\n     */\n    private void checkResponse(JSONObject object) {\n        if (object.containsKey(\"NSP_STATUS\")) {\n            throw new AuthException(object.getString(\"error\"));\n        }\n        if (object.containsKey(\"error\")) {\n            throw new AuthException(object.getString(\"sub_error\") + \":\" + object.getString(\"error_description\"));\n        }\n    }\n\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthJdRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONObject;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.enums.AuthResponseStatus;\nimport me.zhyd.oauth.enums.AuthUserGender;\nimport me.zhyd.oauth.enums.scope.AuthJdScope;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthResponse;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.AuthScopeUtils;\nimport me.zhyd.oauth.utils.GlobalAuthUtils;\nimport me.zhyd.oauth.utils.HttpUtils;\nimport me.zhyd.oauth.utils.UrlBuilder;\n\nimport java.time.LocalDateTime;\nimport java.time.format.DateTimeFormatter;\nimport java.util.HashMap;\nimport java.util.Map;\n\n/**\n * 京东登录\n *\n * @author harry.lee (harryleexyz@qq.com)\n * @since 1.15.0\n */\npublic class AuthJdRequest extends AuthDefaultRequest {\n\n    public AuthJdRequest(AuthConfig config) {\n        super(config, AuthDefaultSource.JD);\n    }\n\n    public AuthJdRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.JD, authStateCache);\n    }\n\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n\n        Map<String, String> params = new HashMap<>(7);\n        params.put(\"app_key\", config.getClientId());\n        params.put(\"app_secret\", config.getClientSecret());\n        params.put(\"grant_type\", \"authorization_code\");\n        params.put(\"code\", authCallback.getCode());\n        String response = new HttpUtils(config.getHttpConfig()).post(source.accessToken(), params, false).getBody();\n        JSONObject object = JSONObject.parseObject(response);\n\n        this.checkResponse(object);\n\n        return AuthToken.builder()\n            .accessToken(object.getString(\"access_token\"))\n            .expireIn(object.getIntValue(\"expires_in\"))\n            .refreshToken(object.getString(\"refresh_token\"))\n            .scope(object.getString(\"scope\"))\n            .openId(object.getString(\"open_id\"))\n            .build();\n    }\n\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        UrlBuilder urlBuilder = UrlBuilder.fromBaseUrl(source.userInfo())\n            .queryParam(\"access_token\", authToken.getAccessToken())\n            .queryParam(\"app_key\", config.getClientId())\n            .queryParam(\"method\", \"jingdong.user.getUserInfoByOpenId\")\n            .queryParam(\"360buy_param_json\", \"{\\\"openId\\\":\\\"\" + authToken.getOpenId() + \"\\\"}\")\n            .queryParam(\"timestamp\", LocalDateTime.now().format(DateTimeFormatter.ofPattern(\"yyyy-MM-dd HH:mm:ss\")))\n            .queryParam(\"v\", \"2.0\");\n        urlBuilder.queryParam(\"sign\", GlobalAuthUtils.generateJdSignature(config.getClientSecret(), urlBuilder.getReadOnlyParams()));\n        String response = new HttpUtils(config.getHttpConfig()).post(urlBuilder.build(true)).getBody();\n        JSONObject object = JSONObject.parseObject(response);\n\n        this.checkResponse(object);\n\n        JSONObject data = this.getUserDataJsonObject(object);\n\n        return AuthUser.builder()\n            .rawUserInfo(data)\n            .uuid(authToken.getOpenId())\n            .username(data.getString(\"nickName\"))\n            .nickname(data.getString(\"nickName\"))\n            .avatar(data.getString(\"imageUrl\"))\n            .gender(AuthUserGender.getRealGender(data.getString(\"gendar\")))\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n\n    /**\n     * 个人用户无法申请应用\n     * 暂时只能参考官网给出的返回结果解析\n     *\n     * @param object 请求返回结果\n     * @return data JSONObject\n     */\n    private JSONObject getUserDataJsonObject(JSONObject object) {\n        return object.getJSONObject(\"jingdong_user_getUserInfoByOpenId_response\")\n            .getJSONObject(\"getuserinfobyappidandopenid_result\")\n            .getJSONObject(\"data\");\n    }\n\n    @Override\n    public AuthResponse<AuthToken> refresh(AuthToken oldToken) {\n        Map<String, String> params = new HashMap<>(7);\n        params.put(\"app_key\", config.getClientId());\n        params.put(\"app_secret\", config.getClientSecret());\n        params.put(\"grant_type\", \"refresh_token\");\n        params.put(\"refresh_token\", oldToken.getRefreshToken());\n        String response = new HttpUtils(config.getHttpConfig()).post(source.refresh(), params, false).getBody();\n        JSONObject object = JSONObject.parseObject(response);\n\n        this.checkResponse(object);\n\n        return AuthResponse.<AuthToken>builder()\n            .code(AuthResponseStatus.SUCCESS.getCode())\n            .data(AuthToken.builder()\n                .accessToken(object.getString(\"access_token\"))\n                .expireIn(object.getIntValue(\"expires_in\"))\n                .refreshToken(object.getString(\"refresh_token\"))\n                .scope(object.getString(\"scope\"))\n                .openId(object.getString(\"open_id\"))\n                .build())\n            .build();\n    }\n\n    private void checkResponse(JSONObject object) {\n        if (object.containsKey(\"error_response\")) {\n            throw new AuthException(object.getJSONObject(\"error_response\").getString(\"zh_desc\"));\n        }\n    }\n\n    @Override\n    public String authorize(String state) {\n        return UrlBuilder.fromBaseUrl(source.authorize())\n            .queryParam(\"app_key\", config.getClientId())\n            .queryParam(\"response_type\", \"code\")\n            .queryParam(\"redirect_uri\", config.getRedirectUri())\n            .queryParam(\"scope\", this.getScopes(\" \", true, AuthScopeUtils.getDefaultScopes(AuthJdScope.values())))\n            .queryParam(\"state\", getRealState(state))\n            .build();\n    }\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthKujialeRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONObject;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.enums.AuthResponseStatus;\nimport me.zhyd.oauth.enums.scope.AuthKujialeScope;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthResponse;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.AuthScopeUtils;\nimport me.zhyd.oauth.utils.HttpUtils;\nimport me.zhyd.oauth.utils.UrlBuilder;\n\n/**\n * 酷家乐授权登录\n *\n * @author shahuang\n * @since 1.11.0\n */\npublic class AuthKujialeRequest extends AuthDefaultRequest {\n\n    public AuthKujialeRequest(AuthConfig config) {\n        super(config, AuthDefaultSource.KUJIALE);\n    }\n\n    public AuthKujialeRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.KUJIALE, authStateCache);\n    }\n\n    /**\n     * 返回带{@code state}参数的授权url，授权回调时会带上这个{@code state}\n     * 默认只向用户请求用户信息授权\n     *\n     * @param state state 验证授权流程的参数，可以防止csrf\n     * @return 返回授权地址\n     * @since 1.11.0\n     */\n    @Override\n    public String authorize(String state) {\n        return UrlBuilder.fromBaseUrl(super.authorize(state))\n            .queryParam(\"scope\", this.getScopes(\",\", false, AuthScopeUtils.getDefaultScopes(AuthKujialeScope.values())))\n            .build();\n    }\n\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        String response = doPostAuthorizationCode(authCallback.getCode());\n        return getAuthToken(response);\n    }\n\n    private AuthToken getAuthToken(String response) {\n        JSONObject accessTokenObject = checkResponse(response);\n        JSONObject resultObject = accessTokenObject.getJSONObject(\"d\");\n        return AuthToken.builder()\n            .accessToken(resultObject.getString(\"accessToken\"))\n            .refreshToken(resultObject.getString(\"refreshToken\"))\n            .expireIn(resultObject.getIntValue(\"expiresIn\"))\n            .build();\n    }\n\n    private JSONObject checkResponse(String response) {\n        JSONObject accessTokenObject = JSONObject.parseObject(response);\n        if (!\"0\".equals(accessTokenObject.getString(\"c\"))) {\n            throw new AuthException(accessTokenObject.getString(\"m\"));\n        }\n        return accessTokenObject;\n    }\n\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        String openId = this.getOpenId(authToken);\n        String response = new HttpUtils(config.getHttpConfig()).get(UrlBuilder.fromBaseUrl(source.userInfo())\n            .queryParam(\"access_token\", authToken.getAccessToken())\n            .queryParam(\"open_id\", openId)\n            .build()).getBody();\n        JSONObject object = JSONObject.parseObject(response);\n        if (!\"0\".equals(object.getString(\"c\"))) {\n            throw new AuthException(object.getString(\"m\"));\n        }\n        JSONObject resultObject = object.getJSONObject(\"d\");\n\n        return AuthUser.builder()\n            .rawUserInfo(resultObject)\n            .username(resultObject.getString(\"userName\"))\n            .nickname(resultObject.getString(\"userName\"))\n            .avatar(resultObject.getString(\"avatar\"))\n            .uuid(resultObject.getString(\"openId\"))\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n\n    /**\n     * 获取酷家乐的openId，此id在当前client范围内可以唯一识别授权用户\n     *\n     * @param authToken 通过{@link AuthKujialeRequest#getAccessToken(AuthCallback)}获取到的{@code authToken}\n     * @return openId\n     */\n    private String getOpenId(AuthToken authToken) {\n        String response = new HttpUtils(config.getHttpConfig()).get(UrlBuilder.fromBaseUrl(\"https://oauth.kujiale.com/oauth2/auth/user\")\n            .queryParam(\"access_token\", authToken.getAccessToken())\n            .build()).getBody();\n        JSONObject accessTokenObject = checkResponse(response);\n        return accessTokenObject.getString(\"d\");\n    }\n\n    @Override\n    public AuthResponse<AuthToken> refresh(AuthToken authToken) {\n        String response = new HttpUtils(config.getHttpConfig()).post(refreshTokenUrl(authToken.getRefreshToken())).getBody();\n        return AuthResponse.<AuthToken>builder().code(AuthResponseStatus.SUCCESS.getCode()).data(getAuthToken(response)).build();\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthLineRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONObject;\nimport com.xkcoding.http.support.HttpHeader;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.enums.AuthResponseStatus;\nimport me.zhyd.oauth.enums.AuthUserGender;\nimport me.zhyd.oauth.enums.scope.AuthLineScope;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthResponse;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.AuthScopeUtils;\nimport me.zhyd.oauth.utils.HttpUtils;\nimport me.zhyd.oauth.utils.UrlBuilder;\n\nimport java.util.HashMap;\nimport java.util.Map;\n\n/**\n * LINE 登录, line.biz\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.16.0\n */\npublic class AuthLineRequest extends AuthDefaultRequest {\n\n    public AuthLineRequest(AuthConfig config) {\n        super(config, AuthDefaultSource.LINE);\n    }\n\n    public AuthLineRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.LINE, authStateCache);\n    }\n\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        Map<String, String> params = new HashMap<>();\n        params.put(\"grant_type\", \"authorization_code\");\n        params.put(\"code\", authCallback.getCode());\n        params.put(\"redirect_uri\", config.getRedirectUri());\n        params.put(\"client_id\", config.getClientId());\n        params.put(\"client_secret\", config.getClientSecret());\n        String response = new HttpUtils(config.getHttpConfig()).post(source.accessToken(), params, false).getBody();\n        JSONObject accessTokenObject = JSONObject.parseObject(response);\n        return AuthToken.builder()\n            .accessToken(accessTokenObject.getString(\"access_token\"))\n            .refreshToken(accessTokenObject.getString(\"refresh_token\"))\n            .expireIn(accessTokenObject.getIntValue(\"expires_in\"))\n            .idToken(accessTokenObject.getString(\"id_token\"))\n            .scope(accessTokenObject.getString(\"scope\"))\n            .tokenType(accessTokenObject.getString(\"token_type\"))\n            .build();\n    }\n\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        String userInfo = new HttpUtils(config.getHttpConfig()).get(source.userInfo(), null, new HttpHeader()\n            .add(\"Content-Type\", \"application/x-www-form-urlencoded\")\n            .add(\"Authorization\", \"Bearer \".concat(authToken.getAccessToken())), false).getBody();\n        JSONObject object = JSONObject.parseObject(userInfo);\n        return AuthUser.builder()\n            .rawUserInfo(object)\n            .uuid(object.getString(\"userId\"))\n            .username(object.getString(\"displayName\"))\n            .nickname(object.getString(\"displayName\"))\n            .avatar(object.getString(\"pictureUrl\"))\n            .remark(object.getString(\"statusMessage\"))\n            .gender(AuthUserGender.UNKNOWN)\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n\n    @Override\n    public AuthResponse revoke(AuthToken authToken) {\n        Map<String, String> params = new HashMap<>(5);\n        params.put(\"access_token\", authToken.getAccessToken());\n        params.put(\"client_id\", config.getClientId());\n        params.put(\"client_secret\", config.getClientSecret());\n        String userInfo = new HttpUtils(config.getHttpConfig()).post(source.revoke(), params, false).getBody();\n        JSONObject object = JSONObject.parseObject(userInfo);\n        // 返回1表示取消授权成功，否则失败\n        AuthResponseStatus status = object.getBooleanValue(\"revoked\") ? AuthResponseStatus.SUCCESS : AuthResponseStatus.FAILURE;\n        return AuthResponse.builder().code(status.getCode()).msg(status.getMsg()).build();\n    }\n\n    @Override\n    public AuthResponse<AuthToken> refresh(AuthToken oldToken) {\n        Map<String, String> params = new HashMap<>();\n        params.put(\"grant_type\", \"refresh_token\");\n        params.put(\"refresh_token\", oldToken.getRefreshToken());\n        params.put(\"client_id\", config.getClientId());\n        params.put(\"client_secret\", config.getClientSecret());\n        String response = new HttpUtils(config.getHttpConfig()).post(source.accessToken(), params, false).getBody();\n        JSONObject accessTokenObject = JSONObject.parseObject(response);\n        return AuthResponse.<AuthToken>builder()\n            .code(AuthResponseStatus.SUCCESS.getCode())\n            .data(AuthToken.builder()\n                .accessToken(accessTokenObject.getString(\"access_token\"))\n                .refreshToken(accessTokenObject.getString(\"refresh_token\"))\n                .expireIn(accessTokenObject.getIntValue(\"expires_in\"))\n                .idToken(accessTokenObject.getString(\"id_token\"))\n                .scope(accessTokenObject.getString(\"scope\"))\n                .tokenType(accessTokenObject.getString(\"token_type\"))\n                .build())\n            .build();\n    }\n\n    @Override\n    public String userInfoUrl(AuthToken authToken) {\n        return UrlBuilder.fromBaseUrl(source.userInfo())\n            .queryParam(\"user\", authToken.getUid())\n            .build();\n    }\n\n    @Override\n    public String authorize(String state) {\n        return UrlBuilder.fromBaseUrl(super.authorize(state))\n            .queryParam(\"nonce\", state)\n            .queryParam(\"scope\", this.getScopes(\" \", true, AuthScopeUtils.getDefaultScopes(AuthLineScope.values())))\n            .build();\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthLinkedinRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONArray;\nimport com.alibaba.fastjson.JSONObject;\nimport com.alibaba.fastjson.JSONPath;\nimport com.xkcoding.http.constants.Constants;\nimport com.xkcoding.http.support.HttpHeader;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.enums.AuthUserGender;\nimport me.zhyd.oauth.enums.scope.AuthLinkedinScope;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.AuthScopeUtils;\nimport me.zhyd.oauth.utils.HttpUtils;\nimport me.zhyd.oauth.utils.UrlBuilder;\n\n\n/**\n * 领英登录\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.4.0\n */\npublic class AuthLinkedinRequest extends AuthDefaultRequest {\n\n    public AuthLinkedinRequest(AuthConfig config) {\n        super(config, AuthDefaultSource.LINKEDIN);\n    }\n\n    public AuthLinkedinRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.LINKEDIN, authStateCache);\n    }\n\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        return this.getToken(accessTokenUrl(authCallback.getCode()));\n    }\n\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        String accessToken = authToken.getAccessToken();\n        HttpHeader httpHeader = new HttpHeader();\n        httpHeader.add(\"Host\", \"api.linkedin.com\");\n        httpHeader.add(\"Connection\", \"Keep-Alive\");\n        httpHeader.add(\"Authorization\", \"Bearer \" + accessToken);\n\n        String response = new HttpUtils(config.getHttpConfig()).get(userInfoUrl(authToken), null, httpHeader, false).getBody();\n        JSONObject userInfoObject = JSONObject.parseObject(response);\n\n        this.checkResponse(userInfoObject);\n\n        String userName = getUserName(userInfoObject);\n\n        // 获取用户头像\n        String avatar = this.getAvatar(userInfoObject);\n\n        // 获取用户邮箱地址\n        String email = this.getUserEmail(accessToken);\n        return AuthUser.builder()\n            .rawUserInfo(userInfoObject)\n            .uuid(userInfoObject.getString(\"id\"))\n            .username(userName)\n            .nickname(userName)\n            .avatar(avatar)\n            .email(email)\n            .token(authToken)\n            .gender(AuthUserGender.UNKNOWN)\n            .source(source.toString())\n            .build();\n    }\n\n    /**\n     * 获取用户的真实名\n     *\n     * @param userInfoObject 用户json对象\n     * @return 用户名\n     */\n    private String getUserName(JSONObject userInfoObject) {\n        String firstName, lastName;\n        // 获取firstName\n        if (userInfoObject.containsKey(\"localizedFirstName\")) {\n            firstName = userInfoObject.getString(\"localizedFirstName\");\n        } else {\n            firstName = getUserName(userInfoObject, \"firstName\");\n        }\n        // 获取lastName\n        if (userInfoObject.containsKey(\"localizedLastName\")) {\n            lastName = userInfoObject.getString(\"localizedLastName\");\n        } else {\n            lastName = getUserName(userInfoObject, \"lastName\");\n        }\n        return firstName + \" \" + lastName;\n    }\n\n    /**\n     * 获取用户的头像\n     *\n     * @param userInfoObject 用户json对象\n     * @return 用户的头像地址\n     */\n    private String getAvatar(JSONObject userInfoObject) {\n        JSONObject profilePictureObject = userInfoObject.getJSONObject(\"profilePicture\");\n        if (null == profilePictureObject || !profilePictureObject.containsKey(\"displayImage~\")) {\n            return null;\n        }\n        JSONObject displayImageObject = profilePictureObject.getJSONObject(\"displayImage~\");\n        if (null == displayImageObject || !displayImageObject.containsKey(\"elements\")) {\n            return null;\n        }\n        JSONArray displayImageElements = displayImageObject.getJSONArray(\"elements\");\n        if (null == displayImageElements || displayImageElements.isEmpty()) {\n            return null;\n        }\n        JSONObject largestImageObj = displayImageElements.getJSONObject(displayImageElements.size() - 1);\n        if (null == largestImageObj || !largestImageObj.containsKey(\"identifiers\")) {\n            return null;\n        }\n        JSONArray identifiers = largestImageObj.getJSONArray(\"identifiers\");\n        if (null == identifiers || identifiers.isEmpty()) {\n            return null;\n        }\n        return identifiers.getJSONObject(0).getString(\"identifier\");\n    }\n\n    /**\n     * 获取用户的email\n     *\n     * @param accessToken 用户授权后返回的token\n     * @return 用户的邮箱地址\n     */\n    private String getUserEmail(String accessToken) {\n        HttpHeader httpHeader = new HttpHeader();\n        httpHeader.add(\"Host\", \"api.linkedin.com\");\n        httpHeader.add(\"Connection\", \"Keep-Alive\");\n        httpHeader.add(\"Authorization\", \"Bearer \" + accessToken);\n\n        String emailResponse = new HttpUtils(config.getHttpConfig())\n            .get(\"https://api.linkedin.com/v2/emailAddress?q=members&projection=(elements*(handle~))\", null, httpHeader, false)\n            .getBody();\n        JSONObject emailObj = JSONObject.parseObject(emailResponse);\n\n        this.checkResponse(emailObj);\n\n        Object obj = JSONPath.eval(emailObj, \"$['elements'][0]['handle~']['emailAddress']\");\n        return null == obj ? null : (String) obj;\n    }\n\n    private String getUserName(JSONObject userInfoObject, String nameKey) {\n        String firstName;\n        JSONObject firstNameObj = userInfoObject.getJSONObject(nameKey);\n        JSONObject localizedObj = firstNameObj.getJSONObject(\"localized\");\n        JSONObject preferredLocaleObj = firstNameObj.getJSONObject(\"preferredLocale\");\n        firstName = localizedObj.getString(preferredLocaleObj.getString(\"language\") + \"_\" + preferredLocaleObj.getString(\"country\"));\n        return firstName;\n    }\n\n    /**\n     * 检查响应内容是否正确\n     *\n     * @param object 请求响应内容\n     */\n    private void checkResponse(JSONObject object) {\n        if (object.containsKey(\"error\")) {\n            throw new AuthException(object.getString(\"error_description\"), source);\n        }\n    }\n\n    /**\n     * 获取token，适用于获取access_token和刷新token\n     *\n     * @param accessTokenUrl 实际请求token的地址\n     * @return token对象\n     */\n    private AuthToken getToken(String accessTokenUrl) {\n        HttpHeader httpHeader = new HttpHeader();\n        httpHeader.add(\"Host\", \"www.linkedin.com\");\n        httpHeader.add(Constants.CONTENT_TYPE, \"application/x-www-form-urlencoded\");\n\n        String response = new HttpUtils(config.getHttpConfig()).post(accessTokenUrl, null, httpHeader).getBody();\n        JSONObject accessTokenObject = JSONObject.parseObject(response);\n\n        this.checkResponse(accessTokenObject);\n\n        return AuthToken.builder()\n            .accessToken(accessTokenObject.getString(\"access_token\"))\n            .expireIn(accessTokenObject.getIntValue(\"expires_in\"))\n            .refreshToken(accessTokenObject.getString(\"refresh_token\"))\n            .build();\n    }\n\n    /**\n     * 返回带{@code state}参数的授权url，授权回调时会带上这个{@code state}\n     *\n     * @param state state 验证授权流程的参数，可以防止csrf\n     * @return 返回授权地址\n     * @since 1.9.3\n     */\n    @Override\n    public String authorize(String state) {\n        return UrlBuilder.fromBaseUrl(super.authorize(state))\n            .queryParam(\"scope\", this.getScopes(\" \", false, AuthScopeUtils.getDefaultScopes(AuthLinkedinScope.values())))\n            .build();\n    }\n\n    /**\n     * 返回获取userInfo的url\n     *\n     * @param authToken 用户授权后的token\n     * @return 返回获取userInfo的url\n     */\n    @Override\n    protected String userInfoUrl(AuthToken authToken) {\n        return UrlBuilder.fromBaseUrl(source.userInfo())\n            .queryParam(\"projection\", \"(id,firstName,lastName,profilePicture(displayImage~:playableStreams))\")\n            .build();\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthMeituanRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONObject;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.enums.AuthResponseStatus;\nimport me.zhyd.oauth.enums.AuthUserGender;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthResponse;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.HttpUtils;\nimport me.zhyd.oauth.utils.UrlBuilder;\n\nimport java.util.HashMap;\nimport java.util.Map;\n\n/**\n * 美团登录\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.12.0\n */\npublic class AuthMeituanRequest extends AuthDefaultRequest {\n\n    public AuthMeituanRequest(AuthConfig config) {\n        super(config, AuthDefaultSource.MEITUAN);\n    }\n\n    public AuthMeituanRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.MEITUAN, authStateCache);\n    }\n\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        Map<String, String> form = new HashMap<>(7);\n        form.put(\"app_id\", config.getClientId());\n        form.put(\"secret\", config.getClientSecret());\n        form.put(\"code\", authCallback.getCode());\n        form.put(\"grant_type\", \"authorization_code\");\n\n        String response = new HttpUtils(config.getHttpConfig()).post(source.accessToken(), form, false).getBody();\n        JSONObject object = JSONObject.parseObject(response);\n\n        this.checkResponse(object);\n\n        return AuthToken.builder()\n            .accessToken(object.getString(\"access_token\"))\n            .refreshToken(object.getString(\"refresh_token\"))\n            .expireIn(object.getIntValue(\"expires_in\"))\n            .build();\n    }\n\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        Map<String, String> form = new HashMap<>(5);\n        form.put(\"app_id\", config.getClientId());\n        form.put(\"secret\", config.getClientSecret());\n        form.put(\"access_token\", authToken.getAccessToken());\n\n        String response = new HttpUtils(config.getHttpConfig()).post(source.userInfo(), form, false).getBody();\n        JSONObject object = JSONObject.parseObject(response);\n\n        this.checkResponse(object);\n\n        return AuthUser.builder()\n            .rawUserInfo(object)\n            .uuid(object.getString(\"openid\"))\n            .username(object.getString(\"nickname\"))\n            .nickname(object.getString(\"nickname\"))\n            .avatar(object.getString(\"avatar\"))\n            .gender(AuthUserGender.UNKNOWN)\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n\n    @Override\n    public AuthResponse<AuthToken> refresh(AuthToken oldToken) {\n        Map<String, String> form = new HashMap<>(7);\n        form.put(\"app_id\", config.getClientId());\n        form.put(\"secret\", config.getClientSecret());\n        form.put(\"refresh_token\", oldToken.getRefreshToken());\n        form.put(\"grant_type\", \"refresh_token\");\n\n        String response = new HttpUtils(config.getHttpConfig()).post(source.refresh(), form, false).getBody();\n        JSONObject object = JSONObject.parseObject(response);\n\n        this.checkResponse(object);\n\n        return AuthResponse.<AuthToken>builder()\n            .code(AuthResponseStatus.SUCCESS.getCode())\n            .data(AuthToken.builder()\n                .accessToken(object.getString(\"access_token\"))\n                .refreshToken(object.getString(\"refresh_token\"))\n                .expireIn(object.getIntValue(\"expires_in\"))\n                .build())\n            .build();\n    }\n\n    private void checkResponse(JSONObject object) {\n        if (object.containsKey(\"error_code\")) {\n            throw new AuthException(object.getString(\"erroe_msg\"));\n        }\n    }\n\n    @Override\n    public String authorize(String state) {\n        return UrlBuilder.fromBaseUrl(super.authorize(state))\n            .queryParam(\"scope\", \"\")\n            .build();\n    }\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthMiRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONObject;\nimport com.xkcoding.http.constants.Constants;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.enums.AuthResponseStatus;\nimport me.zhyd.oauth.enums.AuthUserGender;\nimport me.zhyd.oauth.enums.scope.AuthMiScope;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.log.Log;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthResponse;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.AuthScopeUtils;\nimport me.zhyd.oauth.utils.HttpUtils;\nimport me.zhyd.oauth.utils.UrlBuilder;\n\nimport java.text.MessageFormat;\n\n/**\n * 小米登录\n *\n * @author yangkai.shen (https://xkcoding.com)\n * @since 1.5.0\n */\npublic class AuthMiRequest extends AuthDefaultRequest {\n    private static final String PREFIX = \"&&&START&&&\";\n\n    public AuthMiRequest(AuthConfig config) {\n        super(config, AuthDefaultSource.MI);\n    }\n\n    public AuthMiRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.MI, authStateCache);\n    }\n\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        return getToken(accessTokenUrl(authCallback.getCode()));\n    }\n\n    private AuthToken getToken(String accessTokenUrl) {\n        String response = new HttpUtils(config.getHttpConfig()).get(accessTokenUrl).getBody();\n        String jsonStr = response.replace(PREFIX, Constants.EMPTY);\n        JSONObject accessTokenObject = JSONObject.parseObject(jsonStr);\n\n        if (accessTokenObject.containsKey(\"error\")) {\n            throw new AuthException(accessTokenObject.getString(\"error_description\"));\n        }\n\n        return AuthToken.builder()\n            .accessToken(accessTokenObject.getString(\"access_token\"))\n            .expireIn(accessTokenObject.getIntValue(\"expires_in\"))\n            .scope(accessTokenObject.getString(\"scope\"))\n            .tokenType(accessTokenObject.getString(\"token_type\"))\n            .refreshToken(accessTokenObject.getString(\"refresh_token\"))\n            .openId(accessTokenObject.getString(\"openId\"))\n            .macAlgorithm(accessTokenObject.getString(\"mac_algorithm\"))\n            .macKey(accessTokenObject.getString(\"mac_key\"))\n            .build();\n    }\n\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        // 获取用户信息\n        String userResponse = doGetUserInfo(authToken);\n\n        JSONObject userProfile = JSONObject.parseObject(userResponse);\n        if (\"error\".equalsIgnoreCase(userProfile.getString(\"result\"))) {\n            throw new AuthException(userProfile.getString(\"description\"));\n        }\n\n        JSONObject object = userProfile.getJSONObject(\"data\");\n\n        AuthUser authUser = AuthUser.builder()\n            .rawUserInfo(object)\n            .uuid(authToken.getOpenId())\n            .username(object.getString(\"miliaoNick\"))\n            .nickname(object.getString(\"miliaoNick\"))\n            .avatar(object.getString(\"miliaoIcon\"))\n            .email(object.getString(\"mail\"))\n            .gender(AuthUserGender.UNKNOWN)\n            .token(authToken)\n            .source(source.toString())\n            .build();\n\n        // 获取用户邮箱手机号等信息\n        String emailPhoneUrl = MessageFormat.format(\"{0}?clientId={1}&token={2}\", \"https://open.account.xiaomi.com/user/phoneAndEmail\", config\n            .getClientId(), authToken.getAccessToken());\n\n        String emailResponse = new HttpUtils(config.getHttpConfig()).get(emailPhoneUrl).getBody();\n        JSONObject userEmailPhone = JSONObject.parseObject(emailResponse);\n        if (!\"error\".equalsIgnoreCase(userEmailPhone.getString(\"result\"))) {\n            JSONObject emailPhone = userEmailPhone.getJSONObject(\"data\");\n            authUser.setEmail(emailPhone.getString(\"email\"));\n        } else {\n            Log.warn(\"小米开发平台暂时不对外开放用户手机及邮箱信息的获取\");\n        }\n\n        return authUser;\n    }\n\n    /**\n     * 刷新access token （续期）\n     *\n     * @param authToken 登录成功后返回的Token信息\n     * @return AuthResponse\n     */\n    @Override\n    public AuthResponse<AuthToken> refresh(AuthToken authToken) {\n        return AuthResponse.<AuthToken>builder()\n            .code(AuthResponseStatus.SUCCESS.getCode())\n            .data(getToken(refreshTokenUrl(authToken.getRefreshToken())))\n            .build();\n    }\n\n    /**\n     * 返回带{@code state}参数的授权url，授权回调时会带上这个{@code state}\n     *\n     * @param state state 验证授权流程的参数，可以防止csrf\n     * @return 返回授权地址\n     * @since 1.9.3\n     */\n    @Override\n    public String authorize(String state) {\n        return UrlBuilder.fromBaseUrl(super.authorize(state))\n            .queryParam(\"skip_confirm\", \"false\")\n            .queryParam(\"scope\", this.getScopes(\" \", true, AuthScopeUtils.getDefaultScopes(AuthMiScope.values())))\n            .build();\n    }\n\n    /**\n     * 返回获取userInfo的url\n     *\n     * @param authToken 用户授权后的token\n     * @return 返回获取userInfo的url\n     */\n    @Override\n    protected String userInfoUrl(AuthToken authToken) {\n        return UrlBuilder.fromBaseUrl(source.userInfo())\n            .queryParam(\"clientId\", config.getClientId())\n            .queryParam(\"token\", authToken.getAccessToken())\n            .build();\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthMicrosoftCnRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.enums.AuthResponseStatus;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.utils.GlobalAuthUtils;\n\n/**\n * 微软中国登录(世纪华联)\n *\n * @author mroldx (xzfqq5201314@gmail.com)\n * @since 1.16.4\n */\npublic class AuthMicrosoftCnRequest extends AbstractAuthMicrosoftRequest {\n\n    public AuthMicrosoftCnRequest(AuthConfig config) {\n        super(config, AuthDefaultSource.MICROSOFT_CN);\n    }\n\n    public AuthMicrosoftCnRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.MICROSOFT_CN, authStateCache);\n    }\n\n    @Override\n    protected void checkConfig(AuthConfig config) {\n        super.checkConfig(config);\n        // 微软中国的回调地址必须为https的链接或者localhost,不允许使用http\n        if (AuthDefaultSource.MICROSOFT_CN == source && !GlobalAuthUtils.isHttpsProtocolOrLocalHost(config.getRedirectUri())) {\n            // Microsoft's redirect uri must use the HTTPS or localhost\n            throw new AuthException(AuthResponseStatus.ILLEGAL_REDIRECT_URI, source);\n        }\n    }\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthMicrosoftRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.enums.AuthResponseStatus;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.utils.GlobalAuthUtils;\n\n/**\n * 微软登录\n * update 2021-08-24  mroldx (xzfqq5201314@gmail.com)\n *\n * @author yangkai.shen (https://xkcoding.com)\n * @since 1.5.0\n */\npublic class AuthMicrosoftRequest extends AbstractAuthMicrosoftRequest {\n\n    public AuthMicrosoftRequest(AuthConfig config) {\n        super(config, AuthDefaultSource.MICROSOFT);\n    }\n\n    public AuthMicrosoftRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.MICROSOFT, authStateCache);\n    }\n\n    @Override\n    protected void checkConfig(AuthConfig config) {\n        super.checkConfig(config);\n        // 微软的回调地址必须为https的链接或者localhost,不允许使用http\n        if (AuthDefaultSource.MICROSOFT == source && !GlobalAuthUtils.isHttpsProtocolOrLocalHost(config.getRedirectUri())) {\n            // Microsoft's redirect uri must use the HTTPS or localhost\n            throw new AuthException(AuthResponseStatus.ILLEGAL_REDIRECT_URI, source);\n        }\n    }\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthOktaRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONObject;\nimport com.xkcoding.http.support.HttpHeader;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.enums.AuthResponseStatus;\nimport me.zhyd.oauth.enums.AuthUserGender;\nimport me.zhyd.oauth.enums.scope.AuthOktaScope;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthResponse;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.AuthScopeUtils;\nimport me.zhyd.oauth.utils.Base64Utils;\nimport me.zhyd.oauth.utils.HttpUtils;\nimport me.zhyd.oauth.utils.UrlBuilder;\n\nimport java.util.HashMap;\nimport java.util.Map;\n\n/**\n * Okta 登录\n * <p>\n * https://{domainPrefix}.okta.com/oauth2/default/.well-known/oauth-authorization-server\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.16.0\n */\npublic class AuthOktaRequest extends AuthDefaultRequest {\n\n    public AuthOktaRequest(AuthConfig config) {\n        super(config, AuthDefaultSource.OKTA);\n    }\n\n    public AuthOktaRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.OKTA, authStateCache);\n    }\n\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        String tokenUrl = accessTokenUrl(authCallback.getCode());\n        return getAuthToken(tokenUrl);\n    }\n\n    private AuthToken getAuthToken(String tokenUrl) {\n        HttpHeader header = new HttpHeader()\n            .add(\"accept\", \"application/json\")\n            .add(\"content-type\", \"application/x-www-form-urlencoded\")\n            .add(\"Authorization\", \"Basic \" + Base64Utils.encode(config.getClientId().concat(\":\").concat(config.getClientSecret())));\n        String response = new HttpUtils(config.getHttpConfig()).post(tokenUrl, null, header, false).getBody();\n        JSONObject accessTokenObject = JSONObject.parseObject(response);\n        this.checkResponse(accessTokenObject);\n        return AuthToken.builder()\n            .accessToken(accessTokenObject.getString(\"access_token\"))\n            .tokenType(accessTokenObject.getString(\"token_type\"))\n            .expireIn(accessTokenObject.getIntValue(\"expires_in\"))\n            .scope(accessTokenObject.getString(\"scope\"))\n            .refreshToken(accessTokenObject.getString(\"refresh_token\"))\n            .idToken(accessTokenObject.getString(\"id_token\"))\n            .build();\n    }\n\n    @Override\n    public AuthResponse<AuthToken> refresh(AuthToken authToken) {\n        if (null == authToken.getRefreshToken()) {\n            return AuthResponse.<AuthToken>builder()\n                .code(AuthResponseStatus.ILLEGAL_TOKEN.getCode())\n                .msg(AuthResponseStatus.ILLEGAL_TOKEN.getMsg())\n                .build();\n        }\n        String refreshUrl = refreshTokenUrl(authToken.getRefreshToken());\n        return AuthResponse.<AuthToken>builder()\n            .code(AuthResponseStatus.SUCCESS.getCode())\n            .data(this.getAuthToken(refreshUrl))\n            .build();\n    }\n\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        HttpHeader header = new HttpHeader()\n            .add(\"Authorization\", \"Bearer \" + authToken.getAccessToken());\n        String response = new HttpUtils(config.getHttpConfig()).post(userInfoUrl(authToken), null, header, false).getBody();\n        JSONObject object = JSONObject.parseObject(response);\n        this.checkResponse(object);\n        JSONObject address = object.getJSONObject(\"address\");\n        return AuthUser.builder()\n            .rawUserInfo(object)\n            .uuid(object.getString(\"sub\"))\n            .username(object.getString(\"name\"))\n            .nickname(object.getString(\"nickname\"))\n            .email(object.getString(\"email\"))\n            .location(null == address ? null : address.getString(\"street_address\"))\n            .gender(AuthUserGender.getRealGender(object.getString(\"sex\")))\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n\n    @Override\n    public AuthResponse revoke(AuthToken authToken) {\n        Map<String, String> params = new HashMap<>(4);\n        params.put(\"token\", authToken.getAccessToken());\n        params.put(\"token_type_hint\", \"access_token\");\n\n        HttpHeader header = new HttpHeader()\n            .add(\"Authorization\", \"Basic \" + Base64Utils.encode(config.getClientId().concat(\":\").concat(config.getClientSecret())));\n        new HttpUtils(config.getHttpConfig()).post(revokeUrl(authToken), params, header, false);\n        AuthResponseStatus status = AuthResponseStatus.SUCCESS;\n        return AuthResponse.builder().code(status.getCode()).msg(status.getMsg()).build();\n    }\n\n    private void checkResponse(JSONObject object) {\n        if (object.containsKey(\"error\")) {\n            throw new AuthException(object.getString(\"error_description\"));\n        }\n    }\n\n    @Override\n    public String authorize(String state) {\n        return UrlBuilder.fromBaseUrl(String.format(source.authorize(), config.getDomainPrefix(), config.getAuthServerId()))\n            .queryParam(\"response_type\", \"code\")\n            .queryParam(\"prompt\", \"consent\")\n            .queryParam(\"client_id\", config.getClientId())\n            .queryParam(\"redirect_uri\", config.getRedirectUri())\n            .queryParam(\"scope\", this.getScopes(\" \", true, AuthScopeUtils.getDefaultScopes(AuthOktaScope.values())))\n            .queryParam(\"state\", getRealState(state))\n            .build();\n    }\n\n    @Override\n    public String accessTokenUrl(String code) {\n        return UrlBuilder.fromBaseUrl(String.format(source.accessToken(), config.getDomainPrefix(), config.getAuthServerId()))\n            .queryParam(\"code\", code)\n            .queryParam(\"grant_type\", \"authorization_code\")\n            .queryParam(\"redirect_uri\", config.getRedirectUri())\n            .build();\n    }\n\n    @Override\n    protected String refreshTokenUrl(String refreshToken) {\n        return UrlBuilder.fromBaseUrl(String.format(source.refresh(), config.getDomainPrefix(), config.getAuthServerId()))\n            .queryParam(\"refresh_token\", refreshToken)\n            .queryParam(\"grant_type\", \"refresh_token\")\n            .build();\n    }\n\n    @Override\n    protected String revokeUrl(AuthToken authToken) {\n        return String.format(source.revoke(), config.getDomainPrefix(), config.getAuthServerId());\n    }\n\n    @Override\n    public String userInfoUrl(AuthToken authToken) {\n        return String.format(source.userInfo(), config.getDomainPrefix(), config.getAuthServerId());\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthOschinaRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONObject;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.enums.AuthUserGender;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.UrlBuilder;\n\n/**\n * oschina登录\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.0.0\n */\npublic class AuthOschinaRequest extends AuthDefaultRequest {\n\n    public AuthOschinaRequest(AuthConfig config) {\n        super(config, AuthDefaultSource.OSCHINA);\n    }\n\n    public AuthOschinaRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.OSCHINA, authStateCache);\n    }\n\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        String response = doPostAuthorizationCode(authCallback.getCode());\n        JSONObject accessTokenObject = JSONObject.parseObject(response);\n        this.checkResponse(accessTokenObject);\n        return AuthToken.builder()\n            .accessToken(accessTokenObject.getString(\"access_token\"))\n            .refreshToken(accessTokenObject.getString(\"refresh_token\"))\n            .uid(accessTokenObject.getString(\"uid\"))\n            .expireIn(accessTokenObject.getIntValue(\"expires_in\"))\n            .build();\n    }\n\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        String response = doGetUserInfo(authToken);\n        JSONObject object = JSONObject.parseObject(response);\n        this.checkResponse(object);\n        return AuthUser.builder()\n            .rawUserInfo(object)\n            .uuid(object.getString(\"id\"))\n            .username(object.getString(\"name\"))\n            .nickname(object.getString(\"name\"))\n            .avatar(object.getString(\"avatar\"))\n            .blog(object.getString(\"url\"))\n            .location(object.getString(\"location\"))\n            .gender(AuthUserGender.getRealGender(object.getString(\"gender\")))\n            .email(object.getString(\"email\"))\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n\n    /**\n     * 返回获取accessToken的url\n     *\n     * @param code 授权回调时带回的授权码\n     * @return 返回获取accessToken的url\n     */\n    @Override\n    protected String accessTokenUrl(String code) {\n        return UrlBuilder.fromBaseUrl(source.accessToken())\n            .queryParam(\"code\", code)\n            .queryParam(\"client_id\", config.getClientId())\n            .queryParam(\"client_secret\", config.getClientSecret())\n            .queryParam(\"grant_type\", \"authorization_code\")\n            .queryParam(\"redirect_uri\", config.getRedirectUri())\n            .queryParam(\"dataType\", \"json\")\n            .build();\n    }\n\n    /**\n     * 返回获取userInfo的url\n     *\n     * @param authToken 用户授权后的token\n     * @return 返回获取userInfo的url\n     */\n    @Override\n    protected String userInfoUrl(AuthToken authToken) {\n        return UrlBuilder.fromBaseUrl(source.userInfo())\n            .queryParam(\"access_token\", authToken.getAccessToken())\n            .queryParam(\"dataType\", \"json\")\n            .build();\n    }\n\n    /**\n     * 检查响应内容是否正确\n     *\n     * @param object 请求响应内容\n     */\n    private void checkResponse(JSONObject object) {\n        if (object.containsKey(\"error\")) {\n            throw new AuthException(object.getString(\"error_description\"));\n        }\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthPinterestRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONObject;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.enums.AuthUserGender;\nimport me.zhyd.oauth.enums.scope.AuthPinterestScope;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.AuthScopeUtils;\nimport me.zhyd.oauth.utils.HttpUtils;\nimport me.zhyd.oauth.utils.UrlBuilder;\n\nimport java.util.Objects;\n\nimport static me.zhyd.oauth.config.AuthDefaultSource.PINTEREST;\n\n/**\n * Pinterest登录\n *\n * @author hongwei.peng (pengisgood(at)gmail(dot)com)\n * @since 1.9.0\n */\npublic class AuthPinterestRequest extends AuthDefaultRequest {\n\n    private static final String FAILURE = \"failure\";\n\n    public AuthPinterestRequest(AuthConfig config) {\n        super(config, PINTEREST);\n    }\n\n    public AuthPinterestRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, PINTEREST, authStateCache);\n    }\n\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        String response = doPostAuthorizationCode(authCallback.getCode());\n        JSONObject accessTokenObject = JSONObject.parseObject(response);\n        this.checkResponse(accessTokenObject);\n        return AuthToken.builder()\n            .accessToken(accessTokenObject.getString(\"access_token\"))\n            .tokenType(accessTokenObject.getString(\"token_type\"))\n            .build();\n    }\n\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        String userinfoUrl = userInfoUrl(authToken);\n        // TODO: 是否需要 .setFollowRedirects(true)\n        String response = new HttpUtils(config.getHttpConfig()).get(userinfoUrl).getBody();\n        JSONObject object = JSONObject.parseObject(response);\n        this.checkResponse(object);\n        JSONObject userObj = object.getJSONObject(\"data\");\n        return AuthUser.builder()\n            .rawUserInfo(userObj)\n            .uuid(userObj.getString(\"id\"))\n            .avatar(getAvatarUrl(userObj))\n            .username(userObj.getString(\"username\"))\n            .nickname(userObj.getString(\"first_name\") + \" \" + userObj.getString(\"last_name\"))\n            .gender(AuthUserGender.UNKNOWN)\n            .remark(userObj.getString(\"bio\"))\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n\n    private String getAvatarUrl(JSONObject userObj) {\n        // image is a map data structure\n        JSONObject jsonObject = userObj.getJSONObject(\"image\");\n        if (Objects.isNull(jsonObject)) {\n            return null;\n        }\n        return jsonObject.getJSONObject(\"60x60\").getString(\"url\");\n    }\n\n    /**\n     * 返回带{@code state}参数的授权url，授权回调时会带上这个{@code state}\n     *\n     * @param state state 验证授权流程的参数，可以防止csrf\n     * @return 返回授权地址\n     * @since 1.9.3\n     */\n    @Override\n    public String authorize(String state) {\n        return UrlBuilder.fromBaseUrl(super.authorize(state))\n            .queryParam(\"scope\", this.getScopes(\",\", false, AuthScopeUtils.getDefaultScopes(AuthPinterestScope.values())))\n            .build();\n    }\n\n    /**\n     * 返回获取userInfo的url\n     *\n     * @param authToken token\n     * @return 返回获取userInfo的url\n     */\n    @Override\n    protected String userInfoUrl(AuthToken authToken) {\n        return UrlBuilder.fromBaseUrl(source.userInfo())\n            .queryParam(\"access_token\", authToken.getAccessToken())\n            .queryParam(\"fields\", \"id,username,first_name,last_name,bio,image\")\n            .build();\n    }\n\n    /**\n     * 检查响应内容是否正确\n     *\n     * @param object 请求响应内容\n     */\n    private void checkResponse(JSONObject object) {\n        if (!object.containsKey(\"status\") && FAILURE.equals(object.getString(\"status\"))) {\n            throw new AuthException(object.getString(\"message\"));\n        }\n    }\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthProginnRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONObject;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.enums.AuthUserGender;\nimport me.zhyd.oauth.enums.scope.AuthProginnScope;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.AuthScopeUtils;\nimport me.zhyd.oauth.utils.HttpUtils;\nimport me.zhyd.oauth.utils.UrlBuilder;\n\nimport java.util.HashMap;\nimport java.util.Map;\n\n/**\n * 程序员客栈\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.16.2\n */\npublic class AuthProginnRequest extends AuthDefaultRequest {\n\n    public AuthProginnRequest(AuthConfig config) {\n        super(config, AuthDefaultSource.PROGINN);\n    }\n\n    public AuthProginnRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.PROGINN, authStateCache);\n    }\n\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        Map<String, String> params = new HashMap<>();\n        params.put(\"code\", authCallback.getCode());\n        params.put(\"client_id\", config.getClientId());\n        params.put(\"client_secret\", config.getClientSecret());\n        params.put(\"grant_type\", \"authorization_code\");\n        params.put(\"redirect_uri\", config.getRedirectUri());\n        String response = new HttpUtils(config.getHttpConfig()).post(AuthDefaultSource.PROGINN.accessToken(), params, false).getBody();\n        JSONObject accessTokenObject = JSONObject.parseObject(response);\n        this.checkResponse(accessTokenObject);\n        return AuthToken.builder()\n            .accessToken(accessTokenObject.getString(\"access_token\"))\n            .refreshToken(accessTokenObject.getString(\"refresh_token\"))\n            .uid(accessTokenObject.getString(\"uid\"))\n            .tokenType(accessTokenObject.getString(\"token_type\"))\n            .expireIn(accessTokenObject.getIntValue(\"expires_in\"))\n            .build();\n    }\n\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        String userInfo = doGetUserInfo(authToken);\n        JSONObject object = JSONObject.parseObject(userInfo);\n        this.checkResponse(object);\n        return AuthUser.builder()\n            .rawUserInfo(object)\n            .uuid(object.getString(\"uid\"))\n            .username(object.getString(\"nickname\"))\n            .nickname(object.getString(\"nickname\"))\n            .avatar(object.getString(\"avatar\"))\n            .email(object.getString(\"email\"))\n            .gender(AuthUserGender.UNKNOWN)\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n\n    /**\n     * 检查响应内容是否正确\n     *\n     * @param object 请求响应内容\n     */\n    private void checkResponse(JSONObject object) {\n        if (object.containsKey(\"error\")) {\n            throw new AuthException(object.getString(\"error_description\"));\n        }\n    }\n\n    /**\n     * 返回带{@code state}参数的授权url，授权回调时会带上这个{@code state}\n     *\n     * @param state state 验证授权流程的参数，可以防止csrf\n     * @return 返回授权地址\n     */\n    @Override\n    public String authorize(String state) {\n        return UrlBuilder.fromBaseUrl(super.authorize(state))\n            .queryParam(\"scope\", this.getScopes(\" \", true, AuthScopeUtils.getDefaultScopes(AuthProginnScope.values())))\n            .build();\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthQQMiniProgramRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONObject;\nimport com.alibaba.fastjson.annotation.JSONField;\nimport lombok.Data;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.HttpUtils;\nimport me.zhyd.oauth.utils.UrlBuilder;\n\n/**\n * QQ小程序登陆 Request 请求\n * <p>\n * 参照微信小程序实现\n *\n * @author hurentian\n * @since 2024-10-08\n */\npublic class AuthQQMiniProgramRequest extends AuthDefaultRequest {\n    public AuthQQMiniProgramRequest(AuthConfig config) {\n        super(config, AuthDefaultSource.QQ_MINI_PROGRAM);\n    }\n\n    public AuthQQMiniProgramRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.QQ_MINI_PROGRAM, authStateCache);\n    }\n\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        // 参见 https://q.qq.com/wiki/develop/miniprogram/server/open_port/port_login.html#code2session 文档\n        // 使用 code 获取对应的 openId、unionId 等字段\n        String response = new HttpUtils(config.getHttpConfig()).get(accessTokenUrl(authCallback.getCode())).getBody();\n        JSCode2SessionResponse accessTokenObject = JSONObject.parseObject(response, JSCode2SessionResponse.class);\n        assert accessTokenObject != null;\n        checkResponse(accessTokenObject);\n        // 拼装结果\n        return AuthToken.builder()\n            .openId(accessTokenObject.getOpenid())\n            .unionId(accessTokenObject.getUnionId())\n            .accessToken(accessTokenObject.getSessionKey())\n            .build();\n    }\n\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        // 参见 https://q.qq.com/wiki/develop/game/API/open-port/user-info.html#qq-getuserinfo 文档\n        // 如果需要用户信息，需要在小程序调用函数后传给后端\n        return AuthUser.builder()\n            .username(\"\")\n            .nickname(\"\")\n            .avatar(\"\")\n            .uuid(authToken.getOpenId())\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n\n    /**\n     * 检查响应内容是否正确\n     *\n     * @param response 请求响应内容\n     */\n    private void checkResponse(JSCode2SessionResponse response) {\n        if (response.getErrorCode() != 0) {\n            throw new AuthException(response.getErrorCode(), response.getErrorMsg());\n        }\n    }\n\n    @Override\n    protected String accessTokenUrl(String code) {\n        return UrlBuilder.fromBaseUrl(source.accessToken())\n            .queryParam(\"appid\", config.getClientId())\n            .queryParam(\"secret\", config.getClientSecret())\n            .queryParam(\"js_code\", code)\n            .queryParam(\"grant_type\", \"authorization_code\")\n            .build();\n    }\n\n    @Data\n    @SuppressWarnings(\"SpellCheckingInspection\")\n    private static class JSCode2SessionResponse {\n\n        @JSONField(name = \"errcode\")\n        private int errorCode;\n        @JSONField(name = \"errmsg\")\n        private String errorMsg;\n        @JSONField(name = \"session_key\")\n        private String sessionKey;\n        private String openid;\n        @JSONField(name = \"unionid\")\n        private String unionId;\n\n    }\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthQqRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONObject;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.enums.AuthResponseStatus;\nimport me.zhyd.oauth.enums.AuthUserGender;\nimport me.zhyd.oauth.enums.scope.AuthQqScope;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthResponse;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.*;\n\nimport java.util.Map;\n\n/**\n * qq登录\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @author yangkai.shen (https://xkcoding.com)\n * @since 1.1.0\n */\npublic class AuthQqRequest extends AuthDefaultRequest {\n    public AuthQqRequest(AuthConfig config) {\n        super(config, AuthDefaultSource.QQ);\n    }\n\n    public AuthQqRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.QQ, authStateCache);\n    }\n\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        String response = doGetAuthorizationCode(authCallback.getCode());\n        return getAuthToken(response);\n    }\n\n    @Override\n    public AuthResponse<AuthToken> refresh(AuthToken authToken) {\n        String response = new HttpUtils(config.getHttpConfig()).get(refreshTokenUrl(authToken.getRefreshToken())).getBody();\n        return AuthResponse.<AuthToken>builder().code(AuthResponseStatus.SUCCESS.getCode()).data(getAuthToken(response)).build();\n    }\n\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        String openId = this.getOpenId(authToken);\n        String response = doGetUserInfo(authToken);\n        JSONObject object = JSONObject.parseObject(response);\n        if (object.getIntValue(\"ret\") != 0) {\n            throw new AuthException(object.getString(\"msg\"));\n        }\n        String avatar = object.getString(\"figureurl_qq_2\");\n        if (StringUtils.isEmpty(avatar)) {\n            avatar = object.getString(\"figureurl_qq_1\");\n        }\n\n        String location = String.format(\"%s-%s\", object.getString(\"province\"), object.getString(\"city\"));\n        return AuthUser.builder()\n            .rawUserInfo(object)\n            .username(object.getString(\"nickname\"))\n            .nickname(object.getString(\"nickname\"))\n            .avatar(avatar)\n            .location(location)\n            .uuid(openId)\n            .gender(AuthUserGender.getRealGender(object.getString(\"gender\")))\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n\n    /**\n     * 获取QQ用户的OpenId，支持自定义是否启用查询unionid的功能，如果启用查询unionid的功能，\n     * 那就需要开发者先通过邮件申请unionid功能，参考链接 {@see http://wiki.connect.qq.com/unionid%E4%BB%8B%E7%BB%8D}\n     *\n     * @param authToken 通过{@link AuthQqRequest#getAccessToken(AuthCallback)}获取到的{@code authToken}\n     * @return openId\n     */\n    private String getOpenId(AuthToken authToken) {\n        String response = new HttpUtils(config.getHttpConfig()).get(UrlBuilder.fromBaseUrl(\"https://graph.qq.com/oauth2.0/me\")\n            .queryParam(\"access_token\", authToken.getAccessToken())\n            .queryParam(\"unionid\", config.isUnionId() ? 1 : 0)\n            .build()).getBody();\n        String removePrefix = response.replace(\"callback(\", \"\");\n        String removeSuffix = removePrefix.replace(\");\", \"\");\n        String openId = removeSuffix.trim();\n        JSONObject object = JSONObject.parseObject(openId);\n        if (object.containsKey(\"error\")) {\n            throw new AuthException(object.get(\"error\") + \":\" + object.get(\"error_description\"));\n        }\n        authToken.setOpenId(object.getString(\"openid\"));\n        if (object.containsKey(\"unionid\")) {\n            authToken.setUnionId(object.getString(\"unionid\"));\n        }\n        return StringUtils.isEmpty(authToken.getUnionId()) ? authToken.getOpenId() : authToken.getUnionId();\n    }\n\n    /**\n     * 返回获取userInfo的url\n     *\n     * @param authToken 用户授权token\n     * @return 返回获取userInfo的url\n     */\n    @Override\n    protected String userInfoUrl(AuthToken authToken) {\n        return UrlBuilder.fromBaseUrl(source.userInfo())\n            .queryParam(\"access_token\", authToken.getAccessToken())\n            .queryParam(\"oauth_consumer_key\", config.getClientId())\n            .queryParam(\"openid\", authToken.getOpenId())\n            .build();\n    }\n\n    private AuthToken getAuthToken(String response) {\n        Map<String, String> accessTokenObject = GlobalAuthUtils.parseStringToMap(response);\n        if (!accessTokenObject.containsKey(\"access_token\") || accessTokenObject.containsKey(\"code\")) {\n            throw new AuthException(accessTokenObject.get(\"msg\"));\n        }\n        return AuthToken.builder()\n            .accessToken(accessTokenObject.get(\"access_token\"))\n            .expireIn(Integer.parseInt(accessTokenObject.getOrDefault(\"expires_in\", \"0\")))\n            .refreshToken(accessTokenObject.get(\"refresh_token\"))\n            .build();\n    }\n\n    @Override\n    public String authorize(String state) {\n        return UrlBuilder.fromBaseUrl(super.authorize(state))\n            .queryParam(\"scope\", this.getScopes(\",\", false, AuthScopeUtils.getDefaultScopes(AuthQqScope.values())))\n            .build();\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthRenrenRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONArray;\nimport com.alibaba.fastjson.JSONObject;\nimport com.xkcoding.http.util.UrlUtil;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.enums.AuthUserGender;\nimport me.zhyd.oauth.enums.scope.AuthRenrenScope;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthResponse;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.AuthScopeUtils;\nimport me.zhyd.oauth.utils.HttpUtils;\nimport me.zhyd.oauth.utils.UrlBuilder;\n\nimport java.util.Objects;\n\nimport static me.zhyd.oauth.config.AuthDefaultSource.RENREN;\nimport static me.zhyd.oauth.enums.AuthResponseStatus.SUCCESS;\n\n/**\n * 人人登录\n *\n * @author hongwei.peng (pengisgood(at)gmail(dot)com)\n * @since 1.9.0\n */\npublic class AuthRenrenRequest extends AuthDefaultRequest {\n\n    public AuthRenrenRequest(AuthConfig config) {\n        super(config, RENREN);\n    }\n\n    public AuthRenrenRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, RENREN, authStateCache);\n    }\n\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        return this.getToken(accessTokenUrl(authCallback.getCode()));\n    }\n\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        String response = doGetUserInfo(authToken);\n        JSONObject userObj = JSONObject.parseObject(response).getJSONObject(\"response\");\n\n        return AuthUser.builder()\n            .rawUserInfo(userObj)\n            .uuid(userObj.getString(\"id\"))\n            .avatar(getAvatarUrl(userObj))\n            .nickname(userObj.getString(\"name\"))\n            .company(getCompany(userObj))\n            .gender(getGender(userObj))\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n\n    @Override\n    public AuthResponse<AuthToken> refresh(AuthToken authToken) {\n        return AuthResponse.<AuthToken>builder()\n            .code(SUCCESS.getCode())\n            .data(getToken(this.refreshTokenUrl(authToken.getRefreshToken())))\n            .build();\n    }\n\n    private AuthToken getToken(String url) {\n        String response = new HttpUtils(config.getHttpConfig()).post(url).getBody();\n        JSONObject jsonObject = JSONObject.parseObject(response);\n        if (jsonObject.containsKey(\"error\")) {\n            throw new AuthException(\"Failed to get token from Renren: \" + jsonObject);\n        }\n\n        return AuthToken.builder()\n            .tokenType(jsonObject.getString(\"token_type\"))\n            .expireIn(jsonObject.getIntValue(\"expires_in\"))\n            .accessToken(UrlUtil.urlEncode(jsonObject.getString(\"access_token\")))\n            .refreshToken(UrlUtil.urlEncode(jsonObject.getString(\"refresh_token\")))\n            .openId(jsonObject.getJSONObject(\"user\").getString(\"id\"))\n            .build();\n    }\n\n    private String getAvatarUrl(JSONObject userObj) {\n        JSONArray jsonArray = userObj.getJSONArray(\"avatar\");\n        if (Objects.isNull(jsonArray) || jsonArray.isEmpty()) {\n            return null;\n        }\n        return jsonArray.getJSONObject(0).getString(\"url\");\n    }\n\n    private AuthUserGender getGender(JSONObject userObj) {\n        JSONObject basicInformation = userObj.getJSONObject(\"basicInformation\");\n        if (Objects.isNull(basicInformation)) {\n            return AuthUserGender.UNKNOWN;\n        }\n        return AuthUserGender.getRealGender(basicInformation.getString(\"sex\"));\n    }\n\n    private String getCompany(JSONObject userObj) {\n        JSONArray jsonArray = userObj.getJSONArray(\"work\");\n        if (Objects.isNull(jsonArray) || jsonArray.isEmpty()) {\n            return null;\n        }\n        return jsonArray.getJSONObject(0).getString(\"name\");\n    }\n\n    /**\n     * 返回获取userInfo的url\n     *\n     * @param authToken 用户授权后的token\n     * @return 返回获取userInfo的url\n     */\n    @Override\n    protected String userInfoUrl(AuthToken authToken) {\n        return UrlBuilder.fromBaseUrl(source.userInfo())\n            .queryParam(\"access_token\", authToken.getAccessToken())\n            .queryParam(\"userId\", authToken.getOpenId())\n            .build();\n    }\n\n    @Override\n    public String authorize(String state) {\n        return UrlBuilder.fromBaseUrl(super.authorize(state))\n            .queryParam(\"scope\", this.getScopes(\",\", false, AuthScopeUtils.getDefaultScopes(AuthRenrenScope.values())))\n            .build();\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport me.zhyd.oauth.enums.AuthResponseStatus;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthResponse;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\n\n/**\n * JustAuth {@code Request}公共接口，所有平台的{@code Request}都需要实现该接口\n * <p>\n * {@link AuthRequest#authorize()}\n * {@link AuthRequest#authorize(String)}\n * {@link AuthRequest#login(AuthCallback)}\n * {@link AuthRequest#revoke(AuthToken)}\n * {@link AuthRequest#refresh(AuthToken)}\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.8\n */\npublic interface AuthRequest {\n\n    /**\n     * 返回授权url，可自行跳转页面\n     * <p>\n     * 不建议使用该方式获取授权地址，不带{@code state}的授权地址，容易受到csrf攻击。\n     * 建议使用{@link AuthDefaultRequest#authorize(String)}方法生成授权地址，在回调方法中对{@code state}进行校验\n     *\n     * @return 返回授权地址\n     */\n    @Deprecated\n    default String authorize() {\n        throw new AuthException(AuthResponseStatus.NOT_IMPLEMENTED);\n    }\n\n    /**\n     * 返回带{@code state}参数的授权url，授权回调时会带上这个{@code state}\n     *\n     * @param state state 验证授权流程的参数，可以防止csrf\n     * @return 返回授权地址\n     */\n    default String authorize(String state) {\n        throw new AuthException(AuthResponseStatus.NOT_IMPLEMENTED);\n    }\n\n    /**\n     * 获取access token\n     *\n     * @param authCallback 授权成功后的回调参数\n     * @return token\n     * @see AuthDefaultRequest#authorize()\n     * @see AuthDefaultRequest#authorize(String)\n     */\n    AuthToken getAccessToken(AuthCallback authCallback);\n\n    /**\n     * 使用token换取用户信息\n     *\n     * @param authToken token信息\n     * @return 用户信息\n     * @see AuthDefaultRequest#getAccessToken(AuthCallback)\n     */\n     AuthUser getUserInfo(AuthToken authToken);\n\n    /**\n     * 第三方登录\n     *\n     * @param authCallback 用于接收回调参数的实体\n     * @return 返回登录成功后的用户信息\n     */\n    default AuthResponse<AuthUser> login(AuthCallback authCallback) {\n        throw new AuthException(AuthResponseStatus.NOT_IMPLEMENTED);\n    }\n\n    /**\n     * 撤销授权\n     *\n     * @param authToken 登录成功后返回的Token信息\n     * @return AuthResponse\n     */\n    default AuthResponse revoke(AuthToken authToken) {\n        throw new AuthException(AuthResponseStatus.NOT_IMPLEMENTED);\n    }\n\n    /**\n     * 刷新access token （续期）\n     *\n     * @param authToken 登录成功后返回的Token信息\n     * @return AuthResponse\n     */\n    default AuthResponse<AuthToken> refresh(AuthToken authToken) {\n        throw new AuthException(AuthResponseStatus.NOT_IMPLEMENTED);\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthSlackRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONArray;\nimport com.alibaba.fastjson.JSONObject;\nimport com.xkcoding.http.support.HttpHeader;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.enums.AuthResponseStatus;\nimport me.zhyd.oauth.enums.AuthUserGender;\nimport me.zhyd.oauth.enums.scope.AuthSlackScope;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthResponse;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.AuthScopeUtils;\nimport me.zhyd.oauth.utils.HttpUtils;\nimport me.zhyd.oauth.utils.UrlBuilder;\n\n/**\n * slack登录, slack.com\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.16.0\n */\npublic class AuthSlackRequest extends AuthDefaultRequest {\n\n    public AuthSlackRequest(AuthConfig config) {\n        super(config, AuthDefaultSource.SLACK);\n    }\n\n    public AuthSlackRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.SLACK, authStateCache);\n    }\n\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        HttpHeader header = new HttpHeader()\n            .add(\"Content-Type\", \"application/x-www-form-urlencoded\");\n        String response = new HttpUtils(config.getHttpConfig())\n            .get(accessTokenUrl(authCallback.getCode()), null, header, false).getBody();\n        JSONObject accessTokenObject = JSONObject.parseObject(response);\n        this.checkResponse(accessTokenObject);\n        return AuthToken.builder()\n            .accessToken(accessTokenObject.getString(\"access_token\"))\n            .scope(accessTokenObject.getString(\"scope\"))\n            .tokenType(accessTokenObject.getString(\"token_type\"))\n            .uid(accessTokenObject.getJSONObject(\"authed_user\").getString(\"id\"))\n            .build();\n    }\n\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        HttpHeader header = new HttpHeader()\n            .add(\"Content-Type\", \"application/x-www-form-urlencoded\")\n            .add(\"Authorization\", \"Bearer \".concat(authToken.getAccessToken()));\n        String userInfo = new HttpUtils(config.getHttpConfig())\n            .get(userInfoUrl(authToken), null, header, false).getBody();\n        JSONObject object = JSONObject.parseObject(userInfo);\n        this.checkResponse(object);\n        JSONObject user = object.getJSONObject(\"user\");\n        JSONObject profile = user.getJSONObject(\"profile\");\n        return AuthUser.builder()\n            .rawUserInfo(user)\n            .uuid(user.getString(\"id\"))\n            .username(user.getString(\"name\"))\n            .nickname(user.getString(\"real_name\"))\n            .avatar(profile.getString(\"image_original\"))\n            .email(profile.getString(\"email\"))\n            .gender(AuthUserGender.UNKNOWN)\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n\n    @Override\n    public AuthResponse revoke(AuthToken authToken) {\n        HttpHeader header = new HttpHeader()\n            .add(\"Content-Type\", \"application/x-www-form-urlencoded\")\n            .add(\"Authorization\", \"Bearer \".concat(authToken.getAccessToken()));\n        String userInfo = new HttpUtils(config.getHttpConfig())\n            .get(source.revoke(), null, header, false).getBody();\n        JSONObject object = JSONObject.parseObject(userInfo);\n        this.checkResponse(object);\n        // 返回1表示取消授权成功，否则失败\n        AuthResponseStatus status = object.getBooleanValue(\"revoked\") ? AuthResponseStatus.SUCCESS : AuthResponseStatus.FAILURE;\n        return AuthResponse.builder().code(status.getCode()).msg(status.getMsg()).build();\n    }\n\n    /**\n     * 检查响应内容是否正确\n     *\n     * @param object 请求响应内容\n     */\n    private void checkResponse(JSONObject object) {\n        if (!object.getBooleanValue(\"ok\")) {\n            String errorMsg = object.getString(\"error\");\n            if (object.containsKey(\"response_metadata\")) {\n                JSONArray array = object.getJSONObject(\"response_metadata\").getJSONArray(\"messages\");\n                if (null != array && array.size() > 0) {\n                    errorMsg += \"; \" + String.join(\",\", array.toArray(new String[0]));\n                }\n            }\n\n            throw new AuthException(errorMsg);\n        }\n    }\n\n    @Override\n    public String userInfoUrl(AuthToken authToken) {\n        return UrlBuilder.fromBaseUrl(source.userInfo())\n            .queryParam(\"user\", authToken.getUid())\n            .build();\n    }\n\n    /**\n     * 返回带{@code state}参数的授权url，授权回调时会带上这个{@code state}\n     *\n     * @param state state 验证授权流程的参数，可以防止csrf\n     * @return 返回授权地址\n     */\n    @Override\n    public String authorize(String state) {\n        return UrlBuilder.fromBaseUrl(source.authorize())\n            .queryParam(\"client_id\", config.getClientId())\n            .queryParam(\"state\", getRealState(state))\n            .queryParam(\"redirect_uri\", config.getRedirectUri())\n            .queryParam(\"scope\", this.getScopes(\",\", true, AuthScopeUtils.getDefaultScopes(AuthSlackScope.values())))\n            .build();\n    }\n\n    @Override\n    protected String accessTokenUrl(String code) {\n        return UrlBuilder.fromBaseUrl(source.accessToken())\n            .queryParam(\"code\", code)\n            .queryParam(\"client_id\", config.getClientId())\n            .queryParam(\"client_secret\", config.getClientSecret())\n            .queryParam(\"redirect_uri\", config.getRedirectUri())\n            .build();\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthStackOverflowRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONObject;\nimport com.xkcoding.http.constants.Constants;\nimport com.xkcoding.http.support.HttpHeader;\nimport com.xkcoding.http.util.MapUtil;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.enums.AuthUserGender;\nimport me.zhyd.oauth.enums.scope.AuthStackoverflowScope;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.AuthScopeUtils;\nimport me.zhyd.oauth.utils.HttpUtils;\nimport me.zhyd.oauth.utils.UrlBuilder;\n\nimport java.util.Map;\n\nimport static me.zhyd.oauth.config.AuthDefaultSource.STACK_OVERFLOW;\n\n/**\n * Stack Overflow登录\n *\n * @author hongwei.peng (pengisgood(at)gmail(dot)com)\n * @since 1.9.0\n */\npublic class AuthStackOverflowRequest extends AuthDefaultRequest {\n\n    public AuthStackOverflowRequest(AuthConfig config) {\n        super(config, STACK_OVERFLOW);\n    }\n\n    public AuthStackOverflowRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, STACK_OVERFLOW, authStateCache);\n    }\n\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        String accessTokenUrl = accessTokenUrl(authCallback.getCode());\n        Map<String, String> form = MapUtil.parseStringToMap(accessTokenUrl, false);\n        HttpHeader httpHeader = new HttpHeader();\n        httpHeader.add(Constants.CONTENT_TYPE, \"application/x-www-form-urlencoded\");\n        String response = new HttpUtils(config.getHttpConfig()).post(accessTokenUrl, form, httpHeader, false).getBody();\n\n        JSONObject accessTokenObject = JSONObject.parseObject(response);\n        this.checkResponse(accessTokenObject);\n\n        return AuthToken.builder()\n            .accessToken(accessTokenObject.getString(\"access_token\"))\n            .expireIn(accessTokenObject.getIntValue(\"expires\"))\n            .build();\n    }\n\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        String userInfoUrl = UrlBuilder.fromBaseUrl(this.source.userInfo())\n            .queryParam(\"access_token\", authToken.getAccessToken())\n            .queryParam(\"site\", \"stackoverflow\")\n            .queryParam(\"key\", this.config.getStackOverflowKey())\n            .build();\n        String response = new HttpUtils(config.getHttpConfig()).get(userInfoUrl).getBody();\n        JSONObject object = JSONObject.parseObject(response);\n        this.checkResponse(object);\n        JSONObject userObj = object.getJSONArray(\"items\").getJSONObject(0);\n\n        return AuthUser.builder()\n            .rawUserInfo(userObj)\n            .uuid(userObj.getString(\"user_id\"))\n            .avatar(userObj.getString(\"profile_image\"))\n            .location(userObj.getString(\"location\"))\n            .nickname(userObj.getString(\"display_name\"))\n            .blog(userObj.getString(\"website_url\"))\n            .gender(AuthUserGender.UNKNOWN)\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n\n    /**\n     * 返回带{@code state}参数的授权url，授权回调时会带上这个{@code state}\n     *\n     * @param state state 验证授权流程的参数，可以防止csrf\n     * @return 返回授权地址\n     * @since 1.9.3\n     */\n    @Override\n    public String authorize(String state) {\n        return UrlBuilder.fromBaseUrl(super.authorize(state))\n            .queryParam(\"scope\", this.getScopes(\",\", false, AuthScopeUtils.getDefaultScopes(AuthStackoverflowScope.values())))\n            .build();\n    }\n\n    /**\n     * 检查响应内容是否正确\n     *\n     * @param object 请求响应内容\n     */\n    private void checkResponse(JSONObject object) {\n        if (object.containsKey(\"error\")) {\n            throw new AuthException(object.getString(\"error_description\"));\n        }\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthTaobaoRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONObject;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.enums.AuthResponseStatus;\nimport me.zhyd.oauth.enums.AuthUserGender;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthResponse;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.GlobalAuthUtils;\nimport me.zhyd.oauth.utils.HttpUtils;\nimport me.zhyd.oauth.utils.StringUtils;\nimport me.zhyd.oauth.utils.UrlBuilder;\n\n/**\n * 淘宝登录\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.1.0\n */\npublic class AuthTaobaoRequest extends AuthDefaultRequest {\n\n    public AuthTaobaoRequest(AuthConfig config) {\n        super(config, AuthDefaultSource.TAOBAO);\n    }\n\n    public AuthTaobaoRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.TAOBAO, authStateCache);\n    }\n\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        return AuthToken.builder().accessCode(authCallback.getCode()).build();\n    }\n\n    private AuthToken getAuthToken(JSONObject object) {\n        this.checkResponse(object);\n\n        return AuthToken.builder()\n            .accessToken(object.getString(\"access_token\"))\n            .expireIn(object.getIntValue(\"expires_in\"))\n            .tokenType(object.getString(\"token_type\"))\n            .idToken(object.getString(\"id_token\"))\n            .refreshToken(object.getString(\"refresh_token\"))\n            .uid(object.getString(\"taobao_user_id\"))\n            .openId(object.getString(\"taobao_open_uid\"))\n            .build();\n    }\n\n    private void checkResponse(JSONObject object) {\n        if (object.containsKey(\"error\")) {\n            throw new AuthException(object.getString(\"error_description\"));\n        }\n    }\n\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        String response = doPostAuthorizationCode(authToken.getAccessCode());\n        JSONObject accessTokenObject = JSONObject.parseObject(response);\n        if (accessTokenObject.containsKey(\"error\")) {\n            throw new AuthException(accessTokenObject.getString(\"error_description\"));\n        }\n        authToken = this.getAuthToken(accessTokenObject);\n\n        String nick = GlobalAuthUtils.urlDecode(accessTokenObject.getString(\"taobao_user_nick\"));\n        return AuthUser.builder()\n            .rawUserInfo(accessTokenObject)\n            .uuid(StringUtils.isEmpty(authToken.getUid()) ? authToken.getOpenId() : authToken.getUid())\n            .username(nick)\n            .nickname(nick)\n            .gender(AuthUserGender.UNKNOWN)\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n\n    @Override\n    public AuthResponse<AuthToken> refresh(AuthToken oldToken) {\n        String tokenUrl = refreshTokenUrl(oldToken.getRefreshToken());\n        String response = new HttpUtils(config.getHttpConfig()).post(tokenUrl).getBody();\n        JSONObject accessTokenObject = JSONObject.parseObject(response);\n        return AuthResponse.<AuthToken>builder()\n            .code(AuthResponseStatus.SUCCESS.getCode())\n            .data(this.getAuthToken(accessTokenObject))\n            .build();\n    }\n\n    /**\n     * 返回带{@code state}参数的授权url，授权回调时会带上这个{@code state}\n     *\n     * @param state state 验证授权流程的参数，可以防止csrf\n     * @return 返回授权地址\n     * @since 1.9.3\n     */\n    @Override\n    public String authorize(String state) {\n        return UrlBuilder.fromBaseUrl(source.authorize())\n            .queryParam(\"response_type\", \"code\")\n            .queryParam(\"client_id\", config.getClientId())\n            .queryParam(\"redirect_uri\", config.getRedirectUri())\n            .queryParam(\"view\", \"web\")\n            .queryParam(\"state\", getRealState(state))\n            .build();\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthTeambitionRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONObject;\nimport me.zhyd.oauth.utils.HttpUtils;\nimport com.xkcoding.http.support.HttpHeader;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.enums.AuthResponseStatus;\nimport me.zhyd.oauth.enums.AuthUserGender;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthResponse;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\n\nimport java.util.HashMap;\nimport java.util.Map;\n\n/**\n * Teambition授权登录\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.9.0\n */\npublic class AuthTeambitionRequest extends AuthDefaultRequest {\n\n    public AuthTeambitionRequest(AuthConfig config) {\n        super(config, AuthDefaultSource.TEAMBITION);\n    }\n\n    public AuthTeambitionRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.TEAMBITION, authStateCache);\n    }\n\n    /**\n     * @param authCallback 回调返回的参数\n     * @return 所有信息\n     */\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        Map<String, String> form = new HashMap<>(7);\n        form.put(\"client_id\", config.getClientId());\n        form.put(\"client_secret\", config.getClientSecret());\n        form.put(\"code\", authCallback.getCode());\n        form.put(\"grant_type\", \"code\");\n\n        String response = new HttpUtils(config.getHttpConfig()).post(source.accessToken(), form, false).getBody();\n        JSONObject accessTokenObject = JSONObject.parseObject(response);\n\n        this.checkResponse(accessTokenObject);\n\n        return AuthToken.builder()\n            .accessToken(accessTokenObject.getString(\"access_token\"))\n            .refreshToken(accessTokenObject.getString(\"refresh_token\"))\n            .build();\n    }\n\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        String accessToken = authToken.getAccessToken();\n\n        HttpHeader httpHeader = new HttpHeader();\n        httpHeader.add(\"Authorization\", \"OAuth2 \" + accessToken);\n\n        String response = new HttpUtils(config.getHttpConfig())\n            .get(source.userInfo(), null, httpHeader, false).getBody();\n        JSONObject object = JSONObject.parseObject(response);\n\n        this.checkResponse(object);\n\n        authToken.setUid(object.getString(\"_id\"));\n\n        return AuthUser.builder()\n            .rawUserInfo(object)\n            .uuid(object.getString(\"_id\"))\n            .username(object.getString(\"name\"))\n            .nickname(object.getString(\"name\"))\n            .avatar(object.getString(\"avatarUrl\"))\n            .blog(object.getString(\"website\"))\n            .location(object.getString(\"location\"))\n            .email(object.getString(\"email\"))\n            .gender(AuthUserGender.UNKNOWN)\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n\n    @Override\n    public AuthResponse<AuthToken> refresh(AuthToken oldToken) {\n        String uid = oldToken.getUid();\n        String refreshToken = oldToken.getRefreshToken();\n\n        Map<String, String> form = new HashMap<>(4);\n        form.put(\"_userId\", uid);\n        form.put(\"refresh_token\", refreshToken);\n        String response = new HttpUtils(config.getHttpConfig()).post(source.refresh(), form, false).getBody();\n        JSONObject refreshTokenObject = JSONObject.parseObject(response);\n\n        this.checkResponse(refreshTokenObject);\n\n        return AuthResponse.<AuthToken>builder()\n            .code(AuthResponseStatus.SUCCESS.getCode())\n            .data(AuthToken.builder()\n                .accessToken(refreshTokenObject.getString(\"access_token\"))\n                .refreshToken(refreshTokenObject.getString(\"refresh_token\"))\n                .build())\n            .build();\n    }\n\n    /**\n     * 检查响应内容是否正确\n     *\n     * @param object 请求响应内容\n     */\n    private void checkResponse(JSONObject object) {\n        if ((object.containsKey(\"message\") && object.containsKey(\"name\"))) {\n            throw new AuthException(object.getString(\"name\") + \", \" + object.getString(\"message\"));\n        }\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthToutiaoRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONObject;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.enums.AuthToutiaoErrorCode;\nimport me.zhyd.oauth.enums.AuthUserGender;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.UrlBuilder;\n\n/**\n * 今日头条登录\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.6.0-beta\n */\npublic class AuthToutiaoRequest extends AuthDefaultRequest {\n\n    public AuthToutiaoRequest(AuthConfig config) {\n        super(config, AuthDefaultSource.TOUTIAO);\n    }\n\n    public AuthToutiaoRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.TOUTIAO, authStateCache);\n    }\n\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        String response = doGetAuthorizationCode(authCallback.getCode());\n        JSONObject accessTokenObject = JSONObject.parseObject(response);\n\n        this.checkResponse(accessTokenObject);\n\n        return AuthToken.builder()\n            .accessToken(accessTokenObject.getString(\"access_token\"))\n            .expireIn(accessTokenObject.getIntValue(\"expires_in\"))\n            .openId(accessTokenObject.getString(\"open_id\"))\n            .build();\n    }\n\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        String userResponse = doGetUserInfo(authToken);\n\n        JSONObject userProfile = JSONObject.parseObject(userResponse);\n\n        this.checkResponse(userProfile);\n\n        JSONObject user = userProfile.getJSONObject(\"data\");\n\n        boolean isAnonymousUser = user.getIntValue(\"uid_type\") == 14;\n        String anonymousUserName = \"匿名用户\";\n\n        return AuthUser.builder()\n            .rawUserInfo(user)\n            .uuid(user.getString(\"uid\"))\n            .username(isAnonymousUser ? anonymousUserName : user.getString(\"screen_name\"))\n            .nickname(isAnonymousUser ? anonymousUserName : user.getString(\"screen_name\"))\n            .avatar(user.getString(\"avatar_url\"))\n            .remark(user.getString(\"description\"))\n            .gender(AuthUserGender.getRealGender(user.getString(\"gender\")))\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n\n    /**\n     * 返回带{@code state}参数的授权url，授权回调时会带上这个{@code state}\n     *\n     * @param state state 验证授权流程的参数，可以防止csrf\n     * @return 返回授权地址\n     * @since 1.9.3\n     */\n    @Override\n    public String authorize(String state) {\n        return UrlBuilder.fromBaseUrl(source.authorize())\n            .queryParam(\"response_type\", \"code\")\n            .queryParam(\"client_key\", config.getClientId())\n            .queryParam(\"redirect_uri\", config.getRedirectUri())\n            .queryParam(\"auth_only\", 1)\n            .queryParam(\"display\", 0)\n            .queryParam(\"state\", getRealState(state))\n            .build();\n    }\n\n    /**\n     * 返回获取accessToken的url\n     *\n     * @param code 授权码\n     * @return 返回获取accessToken的url\n     */\n    @Override\n    protected String accessTokenUrl(String code) {\n        return UrlBuilder.fromBaseUrl(source.accessToken())\n            .queryParam(\"code\", code)\n            .queryParam(\"client_key\", config.getClientId())\n            .queryParam(\"client_secret\", config.getClientSecret())\n            .queryParam(\"grant_type\", \"authorization_code\")\n            .build();\n    }\n\n    /**\n     * 返回获取userInfo的url\n     *\n     * @param authToken 用户授权后的token\n     * @return 返回获取userInfo的url\n     */\n    @Override\n    protected String userInfoUrl(AuthToken authToken) {\n        return UrlBuilder.fromBaseUrl(source.userInfo())\n            .queryParam(\"client_key\", config.getClientId())\n            .queryParam(\"access_token\", authToken.getAccessToken())\n            .build();\n    }\n\n    /**\n     * 检查响应内容是否正确\n     *\n     * @param object 请求响应内容\n     */\n    private void checkResponse(JSONObject object) {\n        if (object.containsKey(\"error_code\")) {\n            throw new AuthException(AuthToutiaoErrorCode.getErrorCode(object.getIntValue(\"error_code\")).getDesc());\n        }\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthTwitterRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONObject;\nimport com.xkcoding.http.constants.Constants;\nimport com.xkcoding.http.support.HttpHeader;\nimport com.xkcoding.http.util.MapUtil;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.GlobalAuthUtils;\nimport me.zhyd.oauth.utils.HttpUtils;\nimport me.zhyd.oauth.utils.UrlBuilder;\n\nimport java.util.HashMap;\nimport java.util.Map;\n\nimport static me.zhyd.oauth.config.AuthDefaultSource.TWITTER;\nimport static me.zhyd.oauth.utils.GlobalAuthUtils.generateTwitterSignature;\nimport static me.zhyd.oauth.utils.GlobalAuthUtils.urlEncode;\n\n/**\n * Twitter登录\n *\n * @author hongwei.peng (pengisgood(at)gmail(dot)com)\n * @since 1.13.0\n */\npublic class AuthTwitterRequest extends AuthDefaultRequest {\n\n    private static final String PREAMBLE = \"OAuth\";\n\n    public AuthTwitterRequest(AuthConfig config) {\n        super(config, TWITTER);\n    }\n\n    public AuthTwitterRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, TWITTER, authStateCache);\n    }\n\n    /**\n     * 返回带{@code state}参数的授权url，授权回调时会带上这个{@code state}\n     *\n     * @param state state 验证授权流程的参数，可以防止csrf\n     * @return 返回授权地址\n     * @since 1.9.3\n     */\n    @Override\n    public String authorize(String state) {\n        AuthToken token = this.getRequestToken();\n        return UrlBuilder.fromBaseUrl(source.authorize())\n            .queryParam(\"oauth_token\", token.getOauthToken())\n            .build();\n    }\n\n    /**\n     * Obtaining a request token\n     * https://developer.twitter.com/en/docs/twitter-for-websites/log-in-with-twitter/guides/implementing-sign-in-with-twitter\n     *\n     * @return request token\n     */\n    public AuthToken getRequestToken() {\n        String baseUrl = \"https://api.twitter.com/oauth/request_token\";\n\n        Map<String, String> oauthParams = buildOauthParams();\n        oauthParams.put(\"oauth_callback\", config.getRedirectUri());\n        oauthParams.put(\"oauth_signature\", generateTwitterSignature(oauthParams, \"POST\", baseUrl, config.getClientSecret(), null));\n        String header = buildHeader(oauthParams);\n\n        HttpHeader httpHeader = new HttpHeader();\n        httpHeader.add(\"Authorization\", header);\n        httpHeader.add(\"User-Agent\", \"'JustAuth' HTTP Client Simple-Http\");\n        String requestToken = new HttpUtils(config.getHttpConfig()).post(baseUrl, null, httpHeader).getBody();\n\n        Map<String, String> res = MapUtil.parseStringToMap(requestToken, false);\n\n        return AuthToken.builder()\n            .oauthToken(res.get(\"oauth_token\"))\n            .oauthTokenSecret(res.get(\"oauth_token_secret\"))\n            .oauthCallbackConfirmed(Boolean.valueOf(res.get(\"oauth_callback_confirmed\")))\n            .build();\n    }\n\n    /**\n     * Convert request token to access token\n     * https://developer.twitter.com/en/docs/twitter-for-websites/log-in-with-twitter/guides/implementing-sign-in-with-twitter\n     *\n     * @return access token\n     */\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        Map<String, String> oauthParams = buildOauthParams();\n        oauthParams.put(\"oauth_token\", authCallback.getOauth_token());\n        oauthParams.put(\"oauth_verifier\", authCallback.getOauth_verifier());\n        oauthParams.put(\"oauth_signature\", generateTwitterSignature(oauthParams, \"POST\", source.accessToken(), config.getClientSecret(), authCallback\n            .getOauth_token()));\n        String header = buildHeader(oauthParams);\n\n        HttpHeader httpHeader = new HttpHeader();\n        httpHeader.add(\"Authorization\", header);\n        httpHeader.add(Constants.CONTENT_TYPE, \"application/x-www-form-urlencoded\");\n\n        Map<String, String> form = new HashMap<>(3);\n        form.put(\"oauth_verifier\", authCallback.getOauth_verifier());\n        String response = new HttpUtils(config.getHttpConfig()).post(source.accessToken(), form, httpHeader, false).getBody();\n\n        Map<String, String> requestToken = MapUtil.parseStringToMap(response, false);\n\n        return AuthToken.builder()\n            .oauthToken(requestToken.get(\"oauth_token\"))\n            .oauthTokenSecret(requestToken.get(\"oauth_token_secret\"))\n            .userId(requestToken.get(\"user_id\"))\n            .screenName(requestToken.get(\"screen_name\"))\n            .build();\n    }\n\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        Map<String, String> queryParams = new HashMap<>(5);\n        queryParams.put(\"include_entities\", Boolean.toString(true));\n        queryParams.put(\"include_email\", Boolean.toString(true));\n\n        Map<String, String> oauthParams = buildOauthParams();\n        oauthParams.put(\"oauth_token\", authToken.getOauthToken());\n\n        Map<String, String> params = new HashMap<>(oauthParams);\n        params.putAll(queryParams);\n        oauthParams.put(\"oauth_signature\", generateTwitterSignature(params, \"GET\", source.userInfo(), config.getClientSecret(), authToken.getOauthTokenSecret()));\n        String header = buildHeader(oauthParams);\n\n        HttpHeader httpHeader = new HttpHeader();\n        httpHeader.add(\"Authorization\", header);\n        String response = new HttpUtils(config.getHttpConfig())\n            .get(userInfoUrl(authToken), null, httpHeader, false).getBody();\n        JSONObject userInfo = JSONObject.parseObject(response);\n\n        return AuthUser.builder()\n            .rawUserInfo(userInfo)\n            .uuid(userInfo.getString(\"id_str\"))\n            .username(userInfo.getString(\"screen_name\"))\n            .nickname(userInfo.getString(\"name\"))\n            .remark(userInfo.getString(\"description\"))\n            .avatar(userInfo.getString(\"profile_image_url_https\"))\n            .blog(userInfo.getString(\"url\"))\n            .location(userInfo.getString(\"location\"))\n            .avatar(userInfo.getString(\"profile_image_url\"))\n            .email(userInfo.getString(\"email\"))\n            .source(source.toString())\n            .token(authToken)\n            .build();\n    }\n\n    @Override\n    protected String userInfoUrl(AuthToken authToken) {\n        return UrlBuilder.fromBaseUrl(source.userInfo())\n            .queryParam(\"include_entities\", true)\n            .queryParam(\"include_email\", true)\n            .build();\n    }\n\n    private Map<String, String> buildOauthParams() {\n        Map<String, String> params = new HashMap<>(12);\n        params.put(\"oauth_consumer_key\", config.getClientId());\n        params.put(\"oauth_nonce\", GlobalAuthUtils.generateNonce(32));\n        params.put(\"oauth_signature_method\", \"HMAC-SHA1\");\n        params.put(\"oauth_timestamp\", GlobalAuthUtils.getTimestamp());\n        params.put(\"oauth_version\", \"1.0\");\n        return params;\n    }\n\n    private String buildHeader(Map<String, String> oauthParams) {\n        final StringBuilder sb = new StringBuilder(PREAMBLE + \" \");\n\n        for (Map.Entry<String, String> param : oauthParams.entrySet()) {\n            sb.append(param.getKey()).append(\"=\\\"\").append(urlEncode(param.getValue())).append('\"').append(\", \");\n        }\n\n        return sb.deleteCharAt(sb.length() - 2).toString();\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthWeChatEnterpriseQrcodeRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.utils.UrlBuilder;\n\n/**\n * <p>\n * 企业微信二维码登录\n * </p>\n *\n * @author yangkai.shen (https://xkcoding.com)\n * @author liguanhua (347826496(a)qq.com) 重构该类，将通用方法提取\n * @author lyadong.zhang (yadong.zhang0415(a)gmail.com) 修改类名\n * @since 1.10.0\n */\npublic class AuthWeChatEnterpriseQrcodeRequest extends AbstractAuthWeChatEnterpriseRequest {\n    public AuthWeChatEnterpriseQrcodeRequest(AuthConfig config) {\n        super(config, AuthDefaultSource.WECHAT_ENTERPRISE);\n    }\n\n    public AuthWeChatEnterpriseQrcodeRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.WECHAT_ENTERPRISE, authStateCache);\n    }\n\n    @Override\n    public String authorize(String state) {\n        return UrlBuilder.fromBaseUrl(source.authorize())\n            .queryParam(\"appid\", config.getClientId())\n            .queryParam(\"agentid\", config.getAgentId())\n            .queryParam(\"redirect_uri\", config.getRedirectUri())\n            .queryParam(\"state\", getRealState(state))\n            .queryParam(\"lang\", config.getLang())\n            .build();\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthWeChatEnterpriseQrcodeV2Request.java",
    "content": "package me.zhyd.oauth.request;\n\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.enums.AuthResponseStatus;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.utils.GlobalAuthUtils;\nimport me.zhyd.oauth.utils.StringUtils;\nimport me.zhyd.oauth.utils.UrlBuilder;\n\n/**\n * <p>\n * 新版企业微信 Web 登录，参考 <a href=\"https://developer.work.weixin.qq.com/document/path/98152\">https://developer.work.weixin.qq.com/document/path/98152</a>\n * </p>\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.16.7\n */\npublic class AuthWeChatEnterpriseQrcodeV2Request extends AbstractAuthWeChatEnterpriseRequest {\n    public AuthWeChatEnterpriseQrcodeV2Request(AuthConfig config) {\n        super(config, AuthDefaultSource.WECHAT_ENTERPRISE_V2);\n    }\n\n    public AuthWeChatEnterpriseQrcodeV2Request(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.WECHAT_ENTERPRISE_V2, authStateCache);\n    }\n\n    @Override\n    public String authorize(String state) {\n        return UrlBuilder.fromBaseUrl(source.authorize())\n            .queryParam(\"login_type\", config.getLoginType())\n            // 登录类型为企业自建应用/服务商代开发应用时填企业 CorpID，第三方登录时填登录授权 SuiteID\n            .queryParam(\"appid\", config.getClientId())\n            // 企业自建应用/服务商代开发应用 AgentID，当login_type=CorpApp时填写\n            .queryParam(\"agentid\", config.getAgentId())\n            .queryParam(\"redirect_uri\", GlobalAuthUtils.urlEncode(config.getRedirectUri()))\n            .queryParam(\"state\", getRealState(state))\n            .queryParam(\"lang\", config.getLang())\n            .build()\n            .concat(\"#wechat_redirect\");\n    }\n\n    @Override\n    protected void checkConfig(AuthConfig config) {\n        super.checkConfig(config);\n        if (\"CorpApp\".equals(config.getLoginType()) && StringUtils.isEmpty(config.getAgentId())) {\n            throw new AuthException(AuthResponseStatus.ILLEGAL_WECHAT_AGENT_ID, source);\n        }\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthWeChatEnterpriseThirdQrcodeRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONObject;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.enums.AuthResponseStatus;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.log.Log;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthResponse;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.*;\n\n/**\n * <p>\n * 企业微信第三方二维码登录\n * </p>\n *\n * @author zhengjx\n * @since 1.16.3\n */\npublic class AuthWeChatEnterpriseThirdQrcodeRequest extends AbstractAuthWeChatEnterpriseRequest {\n    public AuthWeChatEnterpriseThirdQrcodeRequest(AuthConfig config) {\n        super(config, AuthDefaultSource.WECHAT_ENTERPRISE_QRCODE_THIRD);\n    }\n\n    public AuthWeChatEnterpriseThirdQrcodeRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.WECHAT_ENTERPRISE_QRCODE_THIRD, authStateCache);\n    }\n\n    @Override\n    public String authorize(String state) {\n        return UrlBuilder.fromBaseUrl(source.authorize())\n            .queryParam(\"appid\", config.getClientId())\n            .queryParam(\"redirect_uri\", config.getRedirectUri())\n            .queryParam(\"state\", getRealState(state))\n            .queryParam(\"usertype\", config.getUsertype())\n            .build();\n    }\n\n    @Override\n    public AuthResponse<AuthUser> login(AuthCallback authCallback) {\n        try {\n            if (!config.isIgnoreCheckState()) {\n                AuthChecker.checkState(authCallback.getState(), source, authStateCache);\n            }\n            AuthToken authToken = this.getAccessToken(authCallback);\n            AuthUser user = this.getUserInfo(authToken);\n            return AuthResponse.<AuthUser>builder().code(AuthResponseStatus.SUCCESS.getCode()).data(user).build();\n        } catch (Exception e) {\n            Log.error(\"Failed to login with oauth authorization.\", e);\n            return this.responseError(e);\n        }\n    }\n\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        try {\n            String response = doGetAuthorizationCode(accessTokenUrl());\n            JSONObject object = this.checkResponse(response);\n            AuthToken authToken = AuthToken.builder()\n                .accessToken(object.getString(\"provider_access_token\"))\n                .expireIn(object.getIntValue(\"expires_in\"))\n                .code(authCallback.getCode())\n                .build();\n            return authToken;\n        } catch (Exception e) {\n            throw new AuthException(\"企业微信获取token失败\", e);\n        }\n    }\n\n    @Override\n    protected String doGetAuthorizationCode(String code) {\n        JSONObject data = new JSONObject();\n        data.put(\"corpid\", config.getClientId());\n        data.put(\"provider_secret\", config.getClientSecret());\n        return new HttpUtils(config.getHttpConfig()).post(accessTokenUrl(code), data.toJSONString()).getBody();\n    }\n\n    /**\n     * 获取token的URL\n     *\n     * @return accessTokenUrl\n     */\n    protected String accessTokenUrl() {\n        return UrlBuilder.fromBaseUrl(source.accessToken())\n            .build();\n    }\n\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        JSONObject response = this.checkResponse(doGetUserInfo(authToken));\n        return AuthUser.builder()\n            .rawUserInfo(response)\n            .build();\n    }\n\n    @Override\n    protected String doGetUserInfo(AuthToken authToken) {\n        JSONObject data = new JSONObject();\n        data.put(\"auth_code\", authToken.getCode());\n        return new HttpUtils(config.getHttpConfig())\n            .post(userInfoUrl(authToken), data.toJSONString()).getBody();\n    }\n\n    @Override\n    protected String userInfoUrl(AuthToken authToken) {\n        return UrlBuilder.fromBaseUrl(source.userInfo())\n            .queryParam(\"access_token\", authToken.getAccessToken()).\n                build();\n    }\n\n    private JSONObject checkResponse(String response) {\n        JSONObject object = JSONObject.parseObject(response);\n        if (object.containsKey(\"errcode\") && object.getIntValue(\"errcode\") != 0) {\n            throw new AuthException(object.getString(\"errmsg\"), source);\n        }\n        return object;\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthWeChatEnterpriseWebRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.enums.scope.AuthWeChatEnterpriseWebScope;\nimport me.zhyd.oauth.utils.AuthScopeUtils;\nimport me.zhyd.oauth.utils.GlobalAuthUtils;\nimport me.zhyd.oauth.utils.UrlBuilder;\n\n/**\n * <p>\n * 企业微信网页登录\n * </p>\n *\n * @author liguanhua (347826496(a)qq.com)\n * @since 1.15.9\n */\npublic class AuthWeChatEnterpriseWebRequest extends AbstractAuthWeChatEnterpriseRequest {\n    public AuthWeChatEnterpriseWebRequest(AuthConfig config) {\n        super(config, AuthDefaultSource.WECHAT_ENTERPRISE_WEB);\n    }\n\n    public AuthWeChatEnterpriseWebRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.WECHAT_ENTERPRISE_WEB, authStateCache);\n    }\n\n    @Override\n    public String authorize(String state) {\n        return UrlBuilder.fromBaseUrl(source.authorize())\n            .queryParam(\"appid\", config.getClientId())\n            .queryParam(\"agentid\", config.getAgentId())\n            .queryParam(\"redirect_uri\", GlobalAuthUtils.urlEncode(config.getRedirectUri()))\n            .queryParam(\"response_type\", \"code\")\n            .queryParam(\"scope\", this.getScopes(\",\", false, AuthScopeUtils.getDefaultScopes(AuthWeChatEnterpriseWebScope.values())))\n            .queryParam(\"state\", getRealState(state).concat(\"#wechat_redirect\"))\n            .build();\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthWeChatMpRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONObject;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.enums.AuthResponseStatus;\nimport me.zhyd.oauth.enums.AuthUserGender;\nimport me.zhyd.oauth.enums.scope.AuthWechatMpScope;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthResponse;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.*;\n\n/**\n * 微信公众平台登录\n *\n * @author yangkai.shen (https://xkcoding.com)\n * @since 1.1.0\n */\npublic class AuthWeChatMpRequest extends AuthDefaultRequest {\n    public AuthWeChatMpRequest(AuthConfig config) {\n        super(config, AuthDefaultSource.WECHAT_MP);\n    }\n\n    public AuthWeChatMpRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.WECHAT_MP, authStateCache);\n    }\n\n    /**\n     * 微信的特殊性，此时返回的信息同时包含 openid 和 access_token\n     *\n     * @param authCallback 回调返回的参数\n     * @return 所有信息\n     */\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        return this.getToken(accessTokenUrl(authCallback.getCode()));\n    }\n\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        String openId = authToken.getOpenId();\n\n        String scope = authToken.getScope();\n        if (!StringUtils.isEmpty(scope) && !scope.contains(\"snsapi_userinfo\")) {\n            return AuthUser.builder()\n                .rawUserInfo(JSONObject.parseObject(JSONObject.toJSONString(authToken)))\n                .uuid(openId)\n                .snapshotUser(authToken.isSnapshotUser())\n                .token(authToken)\n                .source(source.toString())\n                .build();\n        }\n\n        String response = doGetUserInfo(authToken);\n        JSONObject object = JSONObject.parseObject(response);\n\n        this.checkResponse(object);\n        String location = String.format(\"%s-%s-%s\", object.getString(\"country\"), object.getString(\"province\"), object.getString(\"city\"));\n\n        if (object.containsKey(\"unionid\")) {\n            authToken.setUnionId(object.getString(\"unionid\"));\n        }\n        return AuthUser.builder()\n            .rawUserInfo(object)\n            .username(object.getString(\"nickname\"))\n            .nickname(object.getString(\"nickname\"))\n            .avatar(object.getString(\"headimgurl\"))\n            .location(location)\n            .uuid(openId)\n            .snapshotUser(authToken.isSnapshotUser())\n            .gender(AuthUserGender.getWechatRealGender(object.getString(\"sex\")))\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n\n    @Override\n    public AuthResponse<AuthToken> refresh(AuthToken oldToken) {\n        return AuthResponse.<AuthToken>builder()\n            .code(AuthResponseStatus.SUCCESS.getCode())\n            .data(this.getToken(refreshTokenUrl(oldToken.getRefreshToken())))\n            .build();\n    }\n\n    /**\n     * 检查响应内容是否正确\n     *\n     * @param object 请求响应内容\n     */\n    private void checkResponse(JSONObject object) {\n        if (object.containsKey(\"errcode\")) {\n            throw new AuthException(object.getIntValue(\"errcode\"), object.getString(\"errmsg\"));\n        }\n    }\n\n    /**\n     * 获取token，适用于获取access_token和刷新token\n     *\n     * @param accessTokenUrl 实际请求token的地址\n     * @return token对象\n     */\n    private AuthToken getToken(String accessTokenUrl) {\n        String response = new HttpUtils(config.getHttpConfig()).get(accessTokenUrl).getBody();\n        JSONObject accessTokenObject = JSONObject.parseObject(response);\n\n        this.checkResponse(accessTokenObject);\n\n        return AuthToken.builder()\n            .accessToken(accessTokenObject.getString(\"access_token\"))\n            .refreshToken(accessTokenObject.getString(\"refresh_token\"))\n            .expireIn(accessTokenObject.getIntValue(\"expires_in\"))\n            .openId(accessTokenObject.getString(\"openid\"))\n            .scope(accessTokenObject.getString(\"scope\"))\n            .snapshotUser(accessTokenObject.getIntValue(\"is_snapshotuser\") == 1)\n            .build();\n    }\n\n    /**\n     * 返回带{@code state}参数的授权url，授权回调时会带上这个{@code state}\n     *\n     * @param state state 验证授权流程的参数，可以防止csrf\n     * @return 返回授权地址\n     * @since 1.9.3\n     */\n    @Override\n    public String authorize(String state) {\n        return UrlBuilder.fromBaseUrl(source.authorize())\n            .queryParam(\"appid\", config.getClientId())\n            .queryParam(\"redirect_uri\", GlobalAuthUtils.urlEncode(config.getRedirectUri()))\n            .queryParam(\"response_type\", \"code\")\n            .queryParam(\"scope\", this.getScopes(\",\", false, AuthScopeUtils.getDefaultScopes(AuthWechatMpScope.values())))\n            .queryParam(\"state\", getRealState(state).concat(\"#wechat_redirect\"))\n            .build();\n    }\n\n    /**\n     * 返回获取accessToken的url\n     *\n     * @param code 授权码\n     * @return 返回获取accessToken的url\n     */\n    @Override\n    protected String accessTokenUrl(String code) {\n        return UrlBuilder.fromBaseUrl(source.accessToken())\n            .queryParam(\"appid\", config.getClientId())\n            .queryParam(\"secret\", config.getClientSecret())\n            .queryParam(\"code\", code)\n            .queryParam(\"grant_type\", \"authorization_code\")\n            .build();\n    }\n\n    /**\n     * 返回获取userInfo的url\n     *\n     * @param authToken 用户授权后的token\n     * @return 返回获取userInfo的url\n     */\n    @Override\n    protected String userInfoUrl(AuthToken authToken) {\n        return UrlBuilder.fromBaseUrl(source.userInfo())\n            .queryParam(\"access_token\", authToken.getAccessToken())\n            .queryParam(\"openid\", authToken.getOpenId())\n            .queryParam(\"lang\", \"zh_CN\")\n            .build();\n    }\n\n    /**\n     * 返回获取userInfo的url\n     *\n     * @param refreshToken getAccessToken方法返回的refreshToken\n     * @return 返回获取userInfo的url\n     */\n    @Override\n    protected String refreshTokenUrl(String refreshToken) {\n        return UrlBuilder.fromBaseUrl(source.refresh())\n            .queryParam(\"appid\", config.getClientId())\n            .queryParam(\"grant_type\", \"refresh_token\")\n            .queryParam(\"refresh_token\", refreshToken)\n            .build();\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthWeChatOpenRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONObject;\nimport me.zhyd.oauth.utils.HttpUtils;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.enums.AuthResponseStatus;\nimport me.zhyd.oauth.enums.AuthUserGender;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthResponse;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.UrlBuilder;\n\n/**\n * 微信开放平台登录\n *\n * @author yangkai.shen (https://xkcoding.com)\n * @since 1.1.0\n */\npublic class AuthWeChatOpenRequest extends AuthDefaultRequest {\n    public AuthWeChatOpenRequest(AuthConfig config) {\n        super(config, AuthDefaultSource.WECHAT_OPEN);\n    }\n\n    public AuthWeChatOpenRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.WECHAT_OPEN, authStateCache);\n    }\n\n    /**\n     * 微信的特殊性，此时返回的信息同时包含 openid 和 access_token\n     *\n     * @param authCallback 回调返回的参数\n     * @return 所有信息\n     */\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        return this.getToken(accessTokenUrl(authCallback.getCode()));\n    }\n\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        String openId = authToken.getOpenId();\n\n        String response = doGetUserInfo(authToken);\n        JSONObject object = JSONObject.parseObject(response);\n\n        this.checkResponse(object);\n\n        String location = String.format(\"%s-%s-%s\", object.getString(\"country\"), object.getString(\"province\"), object.getString(\"city\"));\n\n        if (object.containsKey(\"unionid\")) {\n            authToken.setUnionId(object.getString(\"unionid\"));\n        }\n\n        return AuthUser.builder()\n            .rawUserInfo(object)\n            .username(object.getString(\"nickname\"))\n            .nickname(object.getString(\"nickname\"))\n            .avatar(object.getString(\"headimgurl\"))\n            .location(location)\n            .uuid(openId)\n            .gender(AuthUserGender.getWechatRealGender(object.getString(\"sex\")))\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n\n    @Override\n    public AuthResponse<AuthToken> refresh(AuthToken oldToken) {\n        return AuthResponse.<AuthToken>builder()\n            .code(AuthResponseStatus.SUCCESS.getCode())\n            .data(this.getToken(refreshTokenUrl(oldToken.getRefreshToken())))\n            .build();\n    }\n\n    /**\n     * 检查响应内容是否正确\n     *\n     * @param object 请求响应内容\n     */\n    private void checkResponse(JSONObject object) {\n        if (object.containsKey(\"errcode\")) {\n            throw new AuthException(object.getIntValue(\"errcode\"), object.getString(\"errmsg\"));\n        }\n    }\n\n    /**\n     * 获取token，适用于获取access_token和刷新token\n     *\n     * @param accessTokenUrl 实际请求token的地址\n     * @return token对象\n     */\n    private AuthToken getToken(String accessTokenUrl) {\n        String response = new HttpUtils(config.getHttpConfig()).get(accessTokenUrl).getBody();\n        JSONObject accessTokenObject = JSONObject.parseObject(response);\n\n        this.checkResponse(accessTokenObject);\n\n        return AuthToken.builder()\n            .accessToken(accessTokenObject.getString(\"access_token\"))\n            .refreshToken(accessTokenObject.getString(\"refresh_token\"))\n            .expireIn(accessTokenObject.getIntValue(\"expires_in\"))\n            .openId(accessTokenObject.getString(\"openid\"))\n            .build();\n    }\n\n    /**\n     * 返回带{@code state}参数的授权url，授权回调时会带上这个{@code state}\n     *\n     * @param state state 验证授权流程的参数，可以防止csrf\n     * @return 返回授权地址\n     * @since 1.9.3\n     */\n    @Override\n    public String authorize(String state) {\n        return UrlBuilder.fromBaseUrl(source.authorize())\n            .queryParam(\"response_type\", \"code\")\n            .queryParam(\"appid\", config.getClientId())\n            .queryParam(\"redirect_uri\", config.getRedirectUri())\n            .queryParam(\"scope\", \"snsapi_login\")\n            .queryParam(\"state\", getRealState(state))\n            .build();\n    }\n\n    /**\n     * 返回获取accessToken的url\n     *\n     * @param code 授权码\n     * @return 返回获取accessToken的url\n     */\n    @Override\n    protected String accessTokenUrl(String code) {\n        return UrlBuilder.fromBaseUrl(source.accessToken())\n            .queryParam(\"code\", code)\n            .queryParam(\"appid\", config.getClientId())\n            .queryParam(\"secret\", config.getClientSecret())\n            .queryParam(\"grant_type\", \"authorization_code\")\n            .build();\n    }\n\n    /**\n     * 返回获取userInfo的url\n     *\n     * @param authToken 用户授权后的token\n     * @return 返回获取userInfo的url\n     */\n    @Override\n    protected String userInfoUrl(AuthToken authToken) {\n        return UrlBuilder.fromBaseUrl(source.userInfo())\n            .queryParam(\"access_token\", authToken.getAccessToken())\n            .queryParam(\"openid\", authToken.getOpenId())\n            .queryParam(\"lang\", \"zh_CN\")\n            .build();\n    }\n\n    /**\n     * 返回获取userInfo的url\n     *\n     * @param refreshToken getAccessToken方法返回的refreshToken\n     * @return 返回获取userInfo的url\n     */\n    @Override\n    protected String refreshTokenUrl(String refreshToken) {\n        return UrlBuilder.fromBaseUrl(source.refresh())\n            .queryParam(\"appid\", config.getClientId())\n            .queryParam(\"refresh_token\", refreshToken)\n            .queryParam(\"grant_type\", \"refresh_token\")\n            .build();\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthWechatMiniProgramRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONObject;\nimport com.alibaba.fastjson.annotation.JSONField;\nimport lombok.Data;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.HttpUtils;\nimport me.zhyd.oauth.utils.UrlBuilder;\n\n/**\n * 微信小程序授权登录\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @author yudaocode\n * @version 1.0.0\n * @since 1.0.0\n */\npublic class AuthWechatMiniProgramRequest extends AuthDefaultRequest {\n    public AuthWechatMiniProgramRequest(AuthConfig config) {\n        super(config, AuthDefaultSource.WECHAT_MINI_PROGRAM);\n    }\n\n    public AuthWechatMiniProgramRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.WECHAT_MINI_PROGRAM, authStateCache);\n    }\n\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        // 参见 https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/login/auth.code2Session.html 文档\n        // 使用 code 获取对应的 openId、unionId 等字段\n        String response = new HttpUtils(config.getHttpConfig()).get(accessTokenUrl(authCallback.getCode())).getBody();\n        JSCode2SessionResponse accessTokenObject = JSONObject.parseObject(response, JSCode2SessionResponse.class);\n        assert accessTokenObject != null;\n        checkResponse(accessTokenObject);\n        // 拼装结果\n        return AuthToken.builder()\n            .openId(accessTokenObject.getOpenid())\n            .unionId(accessTokenObject.getUnionId())\n            .accessToken(accessTokenObject.getSessionKey())\n            .build();\n    }\n\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        // 参见 https://developers.weixin.qq.com/miniprogram/dev/api/open-api/user-info/wx.getUserProfile.html 文档\n        // 如果需要用户信息，需要在小程序调用函数后传给后端\n        return AuthUser.builder()\n            .username(\"\")\n            .nickname(\"\")\n            .avatar(\"\")\n            .uuid(authToken.getOpenId())\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n\n    /**\n     * 检查响应内容是否正确\n     *\n     * @param response 请求响应内容\n     */\n    private void checkResponse(JSCode2SessionResponse response) {\n        if (response.getErrorCode() != 0) {\n            throw new AuthException(response.getErrorCode(), response.getErrorMsg());\n        }\n    }\n\n    @Override\n    protected String accessTokenUrl(String code) {\n        return UrlBuilder.fromBaseUrl(source.accessToken())\n            .queryParam(\"appid\", config.getClientId())\n            .queryParam(\"secret\", config.getClientSecret())\n            .queryParam(\"js_code\", code)\n            .queryParam(\"grant_type\", \"authorization_code\")\n            .build();\n    }\n\n    @Data\n    @SuppressWarnings(\"SpellCheckingInspection\")\n    private static class JSCode2SessionResponse {\n\n        @JSONField(name = \"errcode\")\n        private int errorCode;\n        @JSONField(name = \"errmsg\")\n        private String errorMsg;\n        @JSONField(name = \"session_key\")\n        private String sessionKey;\n        private String openid;\n        @JSONField(name = \"unionid\")\n        private String unionId;\n\n    }\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthWeiboRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONObject;\nimport com.xkcoding.http.support.HttpHeader;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.enums.AuthResponseStatus;\nimport me.zhyd.oauth.enums.AuthUserGender;\nimport me.zhyd.oauth.enums.scope.AuthWeiboScope;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthResponse;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.*;\n\n\n/**\n * 微博登录\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.0.0\n */\npublic class AuthWeiboRequest extends AuthDefaultRequest {\n\n    public AuthWeiboRequest(AuthConfig config) {\n        super(config, AuthDefaultSource.WEIBO);\n    }\n\n    public AuthWeiboRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.WEIBO, authStateCache);\n    }\n\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        String response = doPostAuthorizationCode(authCallback.getCode());\n        JSONObject accessTokenObject = JSONObject.parseObject(response);\n        if (accessTokenObject.containsKey(\"error\")) {\n            throw new AuthException(accessTokenObject.getString(\"error_description\"));\n        }\n        return AuthToken.builder()\n            .accessToken(accessTokenObject.getString(\"access_token\"))\n            .uid(accessTokenObject.getString(\"uid\"))\n            .openId(accessTokenObject.getString(\"uid\"))\n            .expireIn(accessTokenObject.getIntValue(\"expires_in\"))\n            .build();\n    }\n\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        String accessToken = authToken.getAccessToken();\n        String uid = authToken.getUid();\n        String oauthParam = String.format(\"uid=%s&access_token=%s\", uid, accessToken);\n\n        HttpHeader httpHeader = new HttpHeader();\n        httpHeader.add(\"Authorization\", \"OAuth2 \" + oauthParam);\n        httpHeader.add(\"API-RemoteIP\", IpUtils.getLocalIp());\n        String userInfo = new HttpUtils(config.getHttpConfig())\n            .get(userInfoUrl(authToken), null, httpHeader, false).getBody();\n        JSONObject object = JSONObject.parseObject(userInfo);\n        if (object.containsKey(\"error\")) {\n            throw new AuthException(object.getString(\"error\"));\n        }\n        return AuthUser.builder()\n            .rawUserInfo(object)\n            .uuid(object.getString(\"id\"))\n            .username(object.getString(\"name\"))\n            .avatar(object.getString(\"profile_image_url\"))\n            .blog(StringUtils.isEmpty(object.getString(\"url\")) ? \"https://weibo.com/\" + object.getString(\"profile_url\") : object\n                .getString(\"url\"))\n            .nickname(object.getString(\"screen_name\"))\n            .location(object.getString(\"location\"))\n            .remark(object.getString(\"description\"))\n            .gender(AuthUserGender.getRealGender(object.getString(\"gender\")))\n            .token(authToken)\n            .source(source.toString())\n            .build();\n    }\n\n    /**\n     * 返回获取userInfo的url\n     *\n     * @param authToken authToken\n     * @return 返回获取userInfo的url\n     */\n    @Override\n    protected String userInfoUrl(AuthToken authToken) {\n        return UrlBuilder.fromBaseUrl(source.userInfo())\n            .queryParam(\"access_token\", authToken.getAccessToken())\n            .queryParam(\"uid\", authToken.getUid())\n            .build();\n    }\n\n    @Override\n    public String authorize(String state) {\n        return UrlBuilder.fromBaseUrl(super.authorize(state))\n            .queryParam(\"scope\", this.getScopes(\",\", false, AuthScopeUtils.getDefaultScopes(AuthWeiboScope.values())))\n            .build();\n    }\n\n    @Override\n    public AuthResponse revoke(AuthToken authToken) {\n        String response = doGetRevoke(authToken);\n        JSONObject object = JSONObject.parseObject(response);\n        if (object.containsKey(\"error\")) {\n            return AuthResponse.builder()\n                .code(AuthResponseStatus.FAILURE.getCode())\n                .msg(object.getString(\"error\"))\n                .build();\n        }\n        // 返回 result = true 表示取消授权成功，否则失败\n        AuthResponseStatus status = object.getBooleanValue(\"result\") ? AuthResponseStatus.SUCCESS : AuthResponseStatus.FAILURE;\n        return AuthResponse.builder().code(status.getCode()).msg(status.getMsg()).build();\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/AuthXmlyRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSONObject;\nimport com.xkcoding.http.HttpUtil;\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.enums.AuthUserGender;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.GlobalAuthUtils;\nimport me.zhyd.oauth.utils.UrlBuilder;\n\nimport java.util.HashMap;\nimport java.util.Map;\nimport java.util.Optional;\nimport java.util.TreeMap;\n\n/**\n * 喜马拉雅登录\n *\n * @author zwzch (zwzch4j@gmail.com)\n * @since 1.15.9\n */\npublic class AuthXmlyRequest extends AuthDefaultRequest {\n\n    public AuthXmlyRequest(AuthConfig config) {\n        super(config, AuthDefaultSource.XMLY);\n    }\n\n    public AuthXmlyRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthDefaultSource.XMLY, authStateCache);\n    }\n\n    /**\n     * 获取access token\n     *\n     * @param authCallback 授权成功后的回调参数\n     * @return token\n     * @see AuthDefaultRequest#authorize(String)\n     */\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        Map<String, String> map = new HashMap<>(9);\n        map.put(\"code\", authCallback.getCode());\n        map.put(\"client_id\", config.getClientId());\n        map.put(\"client_secret\", config.getClientSecret());\n        map.put(\"device_id\", config.getDeviceId());\n        map.put(\"grant_type\", \"authorization_code\");\n        map.put(\"redirect_uri\", config.getRedirectUri());\n        String response = HttpUtil.post(source.accessToken(), map, true).getBody();\n        JSONObject accessTokenObject = JSONObject.parseObject(response);\n        this.checkResponse(accessTokenObject);\n\n        return AuthToken.builder()\n            .accessToken(accessTokenObject.getString(\"access_token\"))\n            .refreshToken(accessTokenObject.getString(\"refresh_token\"))\n            .expireIn(accessTokenObject.getIntValue(\"expires_in\"))\n            .uid(accessTokenObject.getString(\"uid\"))\n            .build();\n    }\n\n    /**\n     * 返回带{@code state}参数的授权url，授权回调时会带上这个{@code state}\n     *\n     * @param state state 验证授权流程的参数，可以防止csrf\n     * @return 返回授权地址\n     * @since 1.15.8\n     */\n    @Override\n    public String authorize(String state) {\n        return UrlBuilder.fromBaseUrl(source.authorize())\n            .queryParam(\"response_type\", \"code\")\n            .queryParam(\"client_id\", config.getClientId())\n            .queryParam(\"redirect_uri\", config.getRedirectUri())\n            .queryParam(\"state\", getRealState(state))\n            .queryParam(\"client_os_type\", \"3\")\n            .queryParam(\"device_id\", config.getDeviceId())\n            .build();\n    }\n\n    /**\n     * 使用token换取用户信息\n     *\n     * @param authToken token信息\n     * @return 用户信息\n     * @see AuthDefaultRequest#getAccessToken(AuthCallback)\n     */\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        Map<String, String> map = new TreeMap<>();\n        map.put(\"app_key\", config.getClientId());\n        map.put(\"client_os_type\", Optional.ofNullable(config.getClientOsType()).orElse(3).toString());\n        map.put(\"device_id\", config.getDeviceId());\n        map.put(\"pack_id\", config.getPackId());\n        map.put(\"access_token\", authToken.getAccessToken());\n        map.put(\"sig\", GlobalAuthUtils.generateXmlySignature(map, config.getClientSecret()));\n        String rawUserInfo = HttpUtil.get(source.userInfo(), map, false).getBody();\n        JSONObject object = JSONObject.parseObject(rawUserInfo);\n        checkResponse(object);\n        return AuthUser.builder()\n            .uuid(object.getString(\"id\"))\n            .nickname(object.getString(\"nickname\"))\n            .avatar(object.getString(\"avatar_url\"))\n            .rawUserInfo(object)\n            .source(source.toString())\n            .token(authToken)\n            .gender(AuthUserGender.UNKNOWN)\n            .build();\n    }\n\n    /**\n     * 校验响应结果\n     *\n     * @param object 接口返回的结果\n     */\n    private void checkResponse(JSONObject object) {\n        if (object.containsKey(\"errcode\")) {\n            throw new AuthException(object.getIntValue(\"error_no\"), object.getString(\"error_desc\"));\n        }\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/request/package-info.java",
    "content": "/**\n * JustAuth核心组件，所有授权登录都是基于{@code request}实现\n */\npackage me.zhyd.oauth.request;\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/utils/AuthChecker.java",
    "content": "package me.zhyd.oauth.utils;\n\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.config.AuthSource;\nimport me.zhyd.oauth.enums.AuthResponseStatus;\nimport me.zhyd.oauth.exception.AuthException;\nimport me.zhyd.oauth.model.AuthCallback;\n\n/**\n * 授权配置类的校验器\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.6.1-beta\n */\npublic class AuthChecker {\n\n    /**\n     * 是否支持第三方登录\n     *\n     * @param config config\n     * @param source source\n     * @return true or false\n     * @since 1.6.1-beta\n     */\n    public static boolean isSupportedAuth(AuthConfig config, AuthSource source) {\n        boolean isSupported = StringUtils.isNotEmpty(config.getClientId())\n            && StringUtils.isNotEmpty(config.getClientSecret());\n        if (isSupported && AuthDefaultSource.STACK_OVERFLOW == source) {\n            isSupported = StringUtils.isNotEmpty(config.getStackOverflowKey());\n        }\n        if (isSupported && AuthDefaultSource.WECHAT_ENTERPRISE == source) {\n            isSupported = StringUtils.isNotEmpty(config.getAgentId());\n        }\n        if (isSupported && (AuthDefaultSource.CODING == source || AuthDefaultSource.OKTA == source)) {\n            isSupported = StringUtils.isNotEmpty(config.getDomainPrefix());\n        }\n        if (isSupported && AuthDefaultSource.XMLY == source) {\n            isSupported = StringUtils.isNotEmpty(config.getDeviceId()) && null != config.getClientOsType();\n            if (isSupported) {\n                isSupported = config.getClientOsType() == 3 || StringUtils.isNotEmpty(config.getPackId());\n            }\n        }\n        return isSupported;\n    }\n\n    /**\n     * 检查配置合法性。针对部分平台， 对redirect uri有特定要求。一般来说redirect uri都是http://，而对于facebook平台， redirect uri 必须是https的链接\n     *\n     * @param config config\n     * @param source source\n     * @since 1.6.1-beta\n     */\n    public static void checkConfig(AuthConfig config, AuthSource source) {\n        String redirectUri = config.getRedirectUri();\n        if (config.isIgnoreCheckRedirectUri()) {\n            return;\n        }\n        if (StringUtils.isEmpty(redirectUri)) {\n            throw new AuthException(AuthResponseStatus.ILLEGAL_REDIRECT_URI, source);\n        }\n        if (!GlobalAuthUtils.isHttpProtocol(redirectUri) && !GlobalAuthUtils.isHttpsProtocol(redirectUri)) {\n            throw new AuthException(AuthResponseStatus.ILLEGAL_REDIRECT_URI, source);\n        }\n    }\n\n    /**\n     * 校验回调传回的code\n     * <p>\n     * {@code v1.10.0}版本中改为传入{@code source}和{@code callback}，对于不同平台使用不同参数接受code的情况统一做处理\n     *\n     * @param source   当前授权平台\n     * @param callback 从第三方授权回调回来时传入的参数集合\n     * @since 1.8.0\n     */\n    public static void checkCode(AuthSource source, AuthCallback callback) {\n        // 推特平台不支持回调 code 和 state\n        if (source == AuthDefaultSource.TWITTER) {\n            return;\n        }\n        String code = callback.getCode();\n        if (StringUtils.isEmpty(code) && source == AuthDefaultSource.HUAWEI) {\n            code = callback.getAuthorization_code();\n        }\n        if (StringUtils.isEmpty(code)) {\n            throw new AuthException(AuthResponseStatus.ILLEGAL_CODE, source);\n        }\n    }\n\n    /**\n     * 校验回调传回的{@code state}，为空或者不存在\n     * <p>\n     * {@code state}不存在的情况只有两种：\n     * 1. {@code state}已使用，被正常清除\n     * 2. {@code state}为前端伪造，本身就不存在\n     *\n     * @param state          {@code state}一定不为空\n     * @param source         {@code source}当前授权平台\n     * @param authStateCache {@code authStateCache} state缓存实现\n     */\n    public static void checkState(String state, AuthSource source, AuthStateCache authStateCache) {\n        // 推特平台不支持回调 code 和 state\n        if (source == AuthDefaultSource.TWITTER) {\n            return;\n        }\n        if (StringUtils.isEmpty(state) || !authStateCache.containsKey(state)) {\n            throw new AuthException(AuthResponseStatus.ILLEGAL_STATUS, source);\n        }\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/utils/AuthScopeUtils.java",
    "content": "package me.zhyd.oauth.utils;\n\nimport me.zhyd.oauth.enums.scope.AuthScope;\n\nimport java.util.Arrays;\nimport java.util.List;\nimport java.util.stream.Collectors;\n\n/**\n * Scope 工具类，提供对 scope 类的统一操作\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @version 1.0.0\n * @since 1.15.7\n */\npublic class AuthScopeUtils {\n\n    /**\n     * 获取 {@link me.zhyd.oauth.enums.scope.AuthScope} 数组中所有的被标记为 {@code default} 的 scope\n     *\n     * @param scopes scopes\n     * @return List\n     */\n    public static List<String> getDefaultScopes(AuthScope[] scopes) {\n        if (null == scopes || scopes.length == 0) {\n            return null;\n        }\n        return Arrays.stream(scopes)\n            .filter((AuthScope::isDefault))\n            .map(AuthScope::getScope)\n            .collect(Collectors.toList());\n    }\n\n    /**\n     * 从 {@link me.zhyd.oauth.enums.scope.AuthScope} 数组中获取实际的 scope 字符串\n     *\n     * @param scopes 可变参数，支持传任意 {@link me.zhyd.oauth.enums.scope.AuthScope}\n     * @return List\n     */\n    public static List<String> getScopes(AuthScope... scopes) {\n        if (null == scopes || scopes.length == 0) {\n            return null;\n        }\n        return Arrays.stream(scopes).map(AuthScope::getScope).collect(Collectors.toList());\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/utils/AuthStateUtils.java",
    "content": "package me.zhyd.oauth.utils;\n\n/**\n * AuthState工具类，默认只提供一个创建随机uuid的方法\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.9.3\n */\npublic class AuthStateUtils {\n\n    /**\n     * 生成随机state，采用https://github.com/lets-mica/mica的UUID工具\n     *\n     * @return 随机的state字符串\n     */\n    public static String createState() {\n        return UuidUtils.getUUID();\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/utils/Base64Utils.java",
    "content": "package me.zhyd.oauth.utils;\n\nimport java.nio.charset.Charset;\nimport java.nio.charset.StandardCharsets;\n\n/**\n * Base64编码\n *\n * @author looly\n * @since 3.2.0\n */\npublic class Base64Utils {\n\n    private static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8;\n    /**\n     * 标准编码表\n     */\n    private static final byte[] STANDARD_ENCODE_TABLE = { //\n        'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', //\n        'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', //\n        'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', //\n        'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', //\n        'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', //\n        'o', 'p', 'q', 'r', 's', 't', 'u', 'v', //\n        'w', 'x', 'y', 'z', '0', '1', '2', '3', //\n        '4', '5', '6', '7', '8', '9', '+', '/' //\n    };\n    /**\n     * URL安全的编码表，将 + 和 / 替换为 - 和 _\n     */\n    private static final byte[] URL_SAFE_ENCODE_TABLE = { //\n        'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', //\n        'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', //\n        'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', //\n        'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', //\n        'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', //\n        'o', 'p', 'q', 'r', 's', 't', 'u', 'v', //\n        'w', 'x', 'y', 'z', '0', '1', '2', '3', //\n        '4', '5', '6', '7', '8', '9', '-', '_' //\n    };\n\n    // -------------------------------------------------------------------- encode\n\n    /**\n     * 编码为Base64，非URL安全的\n     *\n     * @param arr     被编码的数组\n     * @param lineSep 在76个char之后是CRLF还是EOF\n     * @return 编码后的bytes\n     */\n    public static byte[] encode(byte[] arr, boolean lineSep) {\n        return encode(arr, lineSep, false);\n    }\n\n    /**\n     * 编码为Base64，URL安全的\n     *\n     * @param arr     被编码的数组\n     * @param lineSep 在76个char之后是CRLF还是EOF\n     * @return 编码后的bytes\n     * @since 3.0.6\n     */\n    public static byte[] encodeUrlSafe(byte[] arr, boolean lineSep) {\n        return encode(arr, lineSep, true);\n    }\n\n    /**\n     * base64编码\n     *\n     * @param source 被编码的base64字符串\n     * @return 被加密后的字符串\n     */\n    public static String encode(CharSequence source) {\n        return encode(source, DEFAULT_CHARSET);\n    }\n\n    /**\n     * base64编码，URL安全\n     *\n     * @param source 被编码的base64字符串\n     * @return 被加密后的字符串\n     * @since 3.0.6\n     */\n    public static String encodeUrlSafe(CharSequence source) {\n        return encodeUrlSafe(source, DEFAULT_CHARSET);\n    }\n\n    /**\n     * base64编码\n     *\n     * @param source  被编码的base64字符串\n     * @param charset 字符集\n     * @return 被加密后的字符串\n     */\n    public static String encode(CharSequence source, Charset charset) {\n        return encode(StringUtils.bytes(source, charset));\n    }\n\n    /**\n     * base64编码，URL安全的\n     *\n     * @param source  被编码的base64字符串\n     * @param charset 字符集\n     * @return 被加密后的字符串\n     * @since 3.0.6\n     */\n    public static String encodeUrlSafe(CharSequence source, Charset charset) {\n        return encodeUrlSafe(StringUtils.bytes(source, charset));\n    }\n\n    /**\n     * base64编码\n     *\n     * @param source 被编码的base64字符串\n     * @return 被加密后的字符串\n     */\n    public static String encode(byte[] source) {\n        return StringUtils.str(encode(source, false), DEFAULT_CHARSET);\n    }\n\n    /**\n     * base64编码,URL安全的\n     *\n     * @param source 被编码的base64字符串\n     * @return 被加密后的字符串\n     * @since 3.0.6\n     */\n    public static String encodeUrlSafe(byte[] source) {\n        return StringUtils.str(encodeUrlSafe(source, false), DEFAULT_CHARSET);\n    }\n\n    /**\n     * 编码为Base64<br>\n     * 如果isMultiLine为<code>true</code>，则每76个字符一个换行符，否则在一行显示\n     *\n     * @param arr         被编码的数组\n     * @param isMultiLine 在76个char之后是CRLF还是EOF\n     * @param isUrlSafe   是否使用URL安全字符，一般为<code>false</code>\n     * @return 编码后的bytes\n     */\n    public static byte[] encode(byte[] arr, boolean isMultiLine, boolean isUrlSafe) {\n        if (null == arr) {\n            return null;\n        }\n\n        int len = arr.length;\n        if (len == 0) {\n            return new byte[0];\n        }\n\n        int evenlen = (len / 3) * 3;\n        int cnt = ((len - 1) / 3 + 1) << 2;\n        int destlen = cnt + (isMultiLine ? (cnt - 1) / 76 << 1 : 0);\n        byte[] dest = new byte[destlen];\n\n        byte[] encodeTable = isUrlSafe ? URL_SAFE_ENCODE_TABLE : STANDARD_ENCODE_TABLE;\n\n        for (int s = 0, d = 0, cc = 0; s < evenlen; ) {\n            int i = (arr[s++] & 0xff) << 16 | (arr[s++] & 0xff) << 8 | (arr[s++] & 0xff);\n\n            dest[d++] = encodeTable[(i >>> 18) & 0x3f];\n            dest[d++] = encodeTable[(i >>> 12) & 0x3f];\n            dest[d++] = encodeTable[(i >>> 6) & 0x3f];\n            dest[d++] = encodeTable[i & 0x3f];\n\n            if (isMultiLine && ++cc == 19 && d < destlen - 2) {\n                dest[d++] = '\\r';\n                dest[d++] = '\\n';\n                cc = 0;\n            }\n        }\n\n        int left = len - evenlen;// 剩余位数\n        if (left > 0) {\n            int i = ((arr[evenlen] & 0xff) << 10) | (left == 2 ? ((arr[len - 1] & 0xff) << 2) : 0);\n\n            dest[destlen - 4] = encodeTable[i >> 12];\n            dest[destlen - 3] = encodeTable[(i >>> 6) & 0x3f];\n\n            if (isUrlSafe) {\n                // 在URL Safe模式下，=为URL中的关键字符，不需要补充。空余的byte位要去掉。\n                int urlSafeLen = destlen - 2;\n                if (2 == left) {\n                    dest[destlen - 2] = encodeTable[i & 0x3f];\n                    urlSafeLen += 1;\n                }\n                byte[] urlSafeDest = new byte[urlSafeLen];\n                System.arraycopy(dest, 0, urlSafeDest, 0, urlSafeLen);\n                return urlSafeDest;\n            } else {\n                dest[destlen - 2] = (left == 2) ? encodeTable[i & 0x3f] : (byte) '=';\n                dest[destlen - 1] = '=';\n            }\n        }\n        return dest;\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/utils/GlobalAuthUtils.java",
    "content": "package me.zhyd.oauth.utils;\n\nimport com.alibaba.fastjson.JSON;\nimport me.zhyd.oauth.exception.AuthException;\n\nimport javax.crypto.Mac;\nimport javax.crypto.spec.SecretKeySpec;\nimport java.io.UnsupportedEncodingException;\nimport java.net.URLDecoder;\nimport java.net.URLEncoder;\nimport java.nio.charset.Charset;\nimport java.nio.charset.StandardCharsets;\nimport java.security.InvalidKeyException;\nimport java.security.MessageDigest;\nimport java.security.NoSuchAlgorithmException;\nimport java.util.*;\n\n/**\n * 全局的工具类\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.0.0\n */\npublic class GlobalAuthUtils {\n    private static final Charset DEFAULT_ENCODING = StandardCharsets.UTF_8;\n    private static final String HMAC_SHA1 = \"HmacSHA1\";\n    private static final String HMAC_SHA_256 = \"HmacSHA256\";\n\n    /**\n     * 生成钉钉请求的Signature\n     *\n     * @param secretKey 平台应用的授权密钥\n     * @param timestamp 时间戳\n     * @return Signature\n     */\n    public static String generateDingTalkSignature(String secretKey, String timestamp) {\n        byte[] signData = sign(secretKey.getBytes(DEFAULT_ENCODING), timestamp.getBytes(DEFAULT_ENCODING), HMAC_SHA_256);\n        return urlEncode(new String(Base64Utils.encode(signData, false)));\n    }\n\n    /**\n     * 签名\n     *\n     * @param key       key\n     * @param data      data\n     * @param algorithm algorithm\n     * @return byte[]\n     */\n    private static byte[] sign(byte[] key, byte[] data, String algorithm) {\n        try {\n            Mac mac = Mac.getInstance(algorithm);\n            mac.init(new SecretKeySpec(key, algorithm));\n            return mac.doFinal(data);\n        } catch (NoSuchAlgorithmException ex) {\n            throw new AuthException(\"Unsupported algorithm: \" + algorithm, ex);\n        } catch (InvalidKeyException ex) {\n            throw new AuthException(\"Invalid key: \" + Arrays.toString(key), ex);\n        }\n    }\n\n    /**\n     * 编码\n     *\n     * @param value str\n     * @return encode str\n     */\n    public static String urlEncode(String value) {\n        if (value == null) {\n            return \"\";\n        }\n        try {\n            String encoded = URLEncoder.encode(value, GlobalAuthUtils.DEFAULT_ENCODING.displayName());\n            return encoded.replace(\"+\", \"%20\").replace(\"*\", \"%2A\").replace(\"~\", \"%7E\").replace(\"/\", \"%2F\");\n        } catch (UnsupportedEncodingException e) {\n            throw new AuthException(\"Failed To Encode Uri\", e);\n        }\n    }\n\n\n    /**\n     * 解码\n     *\n     * @param value str\n     * @return decode str\n     */\n    public static String urlDecode(String value) {\n        if (value == null) {\n            return \"\";\n        }\n        try {\n            return URLDecoder.decode(value, GlobalAuthUtils.DEFAULT_ENCODING.displayName());\n        } catch (UnsupportedEncodingException e) {\n            throw new AuthException(\"Failed To Decode Uri\", e);\n        }\n    }\n\n    /**\n     * string字符串转map，str格式为 {@code xxx=xxx&xxx=xxx}\n     *\n     * @param accessTokenStr 待转换的字符串\n     * @return map\n     */\n    public static Map<String, String> parseStringToMap(String accessTokenStr) {\n        Map<String, String> res = null;\n        if (accessTokenStr.contains(\"&\")) {\n            String[] fields = accessTokenStr.split(\"&\");\n            res = new HashMap<>((int) (fields.length / 0.75 + 1));\n            for (String field : fields) {\n                if (field.contains(\"=\")) {\n                    String[] keyValue = field.split(\"=\");\n                    res.put(GlobalAuthUtils.urlDecode(keyValue[0]), keyValue.length == 2 ? GlobalAuthUtils.urlDecode(keyValue[1]) : null);\n                }\n            }\n        } else {\n            res = new HashMap<>(0);\n        }\n        return res;\n    }\n\n    /**\n     * map转字符串，转换后的字符串格式为 {@code xxx=xxx&xxx=xxx}\n     *\n     * @param params 待转换的map\n     * @param encode 是否转码\n     * @return str\n     */\n    public static String parseMapToString(Map<String, String> params, boolean encode) {\n        if (null == params || params.isEmpty()) {\n            return \"\";\n        }\n        List<String> paramList = new ArrayList<>();\n        params.forEach((k, v) -> {\n            if (null == v) {\n                paramList.add(k + \"=\");\n            } else {\n                paramList.add(k + \"=\" + (encode ? urlEncode(v) : v));\n            }\n        });\n        return String.join(\"&\", paramList);\n    }\n\n    /**\n     * 是否为http协议\n     *\n     * @param url 待验证的url\n     * @return true: http协议, false: 非http协议\n     */\n    public static boolean isHttpProtocol(String url) {\n        if (StringUtils.isEmpty(url)) {\n            return false;\n        }\n        return url.startsWith(\"http://\") || url.startsWith(\"http%3A%2F%2F\");\n    }\n\n    /**\n     * 是否为https协议\n     *\n     * @param url 待验证的url\n     * @return true: https协议, false: 非https协议\n     */\n    public static boolean isHttpsProtocol(String url) {\n        if (StringUtils.isEmpty(url)) {\n            return false;\n        }\n        return url.startsWith(\"https://\") || url.startsWith(\"https%3A%2F%2F\");\n    }\n\n    /**\n     * 是否为本地主机（域名）\n     *\n     * @param url 待验证的url\n     * @return true: 本地主机（域名）, false: 非本地主机（域名）\n     */\n    public static boolean isLocalHost(String url) {\n        return StringUtils.isEmpty(url) || url.contains(\"127.0.0.1\") || url.contains(\"localhost\");\n    }\n\n    /**\n     * 是否为https协议或本地主机（域名）\n     *\n     * @param url 待验证的url\n     * @return true: https协议或本地主机 false: 非https协议或本机主机\n     */\n    public static boolean isHttpsProtocolOrLocalHost(String url) {\n        if (StringUtils.isEmpty(url)) {\n            return false;\n        }\n        return isHttpsProtocol(url) || isLocalHost(url);\n    }\n\n\n    /**\n     * Generate nonce with given length\n     *\n     * @param len length\n     * @return nonce string\n     */\n    public static String generateNonce(int len) {\n        String s = \"0123456789QWERTYUIOPLKJHGFDSAZXCVBNMqwertyuioplkjhgfdsazxcvbnm\";\n        Random rng = new Random();\n        StringBuilder sb = new StringBuilder();\n        for (int i = 0; i < len; i++) {\n            int index = rng.nextInt(62);\n            sb.append(s, index, index + 1);\n        }\n        return sb.toString();\n    }\n\n    /**\n     * Get current timestamp\n     *\n     * @return timestamp string\n     */\n    public static String getTimestamp() {\n        return String.valueOf(System.currentTimeMillis() / 1000);\n    }\n\n    /**\n     * Generate Twitter signature\n     * https://developer.twitter.com/en/docs/basics/authentication/guides/creating-a-signature\n     *\n     * @param params      parameters including: oauth headers, query params, body params\n     * @param method      HTTP method\n     * @param baseUrl     base url\n     * @param apiSecret   api key secret can be found in the developer portal by viewing the app details page\n     * @param tokenSecret oauth token secret\n     * @return BASE64 encoded signature string\n     */\n    public static String generateTwitterSignature(Map<String, String> params, String method, String baseUrl, String apiSecret, String tokenSecret) {\n        TreeMap<String, String> map = new TreeMap<>(params);\n        String str = parseMapToString(map, true);\n        String baseStr = method.toUpperCase() + \"&\" + urlEncode(baseUrl) + \"&\" + urlEncode(str);\n        String signKey = apiSecret + \"&\" + (StringUtils.isEmpty(tokenSecret) ? \"\" : tokenSecret);\n        byte[] signature = sign(signKey.getBytes(DEFAULT_ENCODING), baseStr.getBytes(DEFAULT_ENCODING), HMAC_SHA1);\n\n        return new String(Base64Utils.encode(signature, false));\n    }\n\n    /**\n     * 喜马拉雅签名算法\n     * {@code https://open.ximalaya.com/doc/detailApi?categoryId=6&articleId=69}\n     *\n     * @param params       加密参数\n     * @param clientSecret 平台应用的授权key\n     * @return Signature\n     * @since 1.15.9\n     */\n    public static String generateXmlySignature(Map<String, String> params, String clientSecret) {\n        TreeMap<String, String> map = new TreeMap<>(params);\n        String baseStr = Base64Utils.encode(parseMapToString(map, false));\n        byte[] sign = sign(clientSecret.getBytes(DEFAULT_ENCODING), baseStr.getBytes(DEFAULT_ENCODING), HMAC_SHA1);\n        MessageDigest md5 = null;\n        StringBuilder builder = null;\n        try {\n            builder = new StringBuilder();\n            md5 = MessageDigest.getInstance(\"MD5\");\n            md5.update(sign);\n            byte[] byteData = md5.digest();\n            for (byte byteDatum : byteData) {\n                builder.append(Integer.toString((byteDatum & 0xff) + 0x100, 16).substring(1));\n            }\n        } catch (Exception ignored) {\n        }\n        return null == builder ? \"\" : builder.toString();\n    }\n\n    /**\n     * 生成饿了么请求的Signature\n     * <p>\n     * 代码copy并修改自：https://coding.net/u/napos_openapi/p/eleme-openapi-java-sdk/git/blob/master/src/main/java/eleme/openapi/sdk/utils/SignatureUtil.java\n     *\n     * @param appKey     平台应用的授权key\n     * @param secret     平台应用的授权密钥\n     * @param timestamp  时间戳，单位秒。API服务端允许客户端请求最大时间误差为正负5分钟。\n     * @param action     饿了么请求的api方法\n     * @param token      用户授权的token\n     * @param parameters 加密参数\n     * @return Signature\n     */\n    public static String generateElemeSignature(String appKey, String secret, long timestamp, String action, String token, Map<String, Object> parameters) {\n        final Map<String, Object> sorted = new TreeMap<>(parameters);\n        sorted.put(\"app_key\", appKey);\n        sorted.put(\"timestamp\", timestamp);\n        StringBuffer string = new StringBuffer();\n        for (Map.Entry<String, Object> entry : sorted.entrySet()) {\n            string.append(entry.getKey()).append(\"=\").append(JSON.toJSONString(entry.getValue()));\n        }\n        String splice = String.format(\"%s%s%s%s\", action, token, string, secret);\n        String calculatedSignature = md5(splice);\n        return calculatedSignature.toUpperCase();\n    }\n\n    /**\n     * MD5加密\n     * <p>\n     * 代码copy并修改自：https://coding.net/u/napos_openapi/p/eleme-openapi-java-sdk/git/blob/master/src/main/java/eleme/openapi/sdk/utils/SignatureUtil.java\n     *\n     * @param str 待加密的字符串\n     * @return md5 str\n     */\n    public static String md5(String str) {\n        MessageDigest md = null;\n        StringBuilder buffer = null;\n        try {\n            md = MessageDigest.getInstance(\"MD5\");\n            md.update(str.getBytes(StandardCharsets.UTF_8));\n            byte[] byteData = md.digest();\n            buffer = new StringBuilder();\n            for (byte byteDatum : byteData) {\n                buffer.append(Integer.toString((byteDatum & 0xff) + 0x100, 16).substring(1));\n            }\n        } catch (Exception ignored) {\n        }\n\n        return null == buffer ? \"\" : buffer.toString();\n    }\n\n    /**\n     * 生成京东宙斯平台的签名字符串\n     * 宙斯签名规则过程如下:\n     * 将所有请求参数按照字母先后顺序排列，例如将access_token,app_key,method,timestamp,v 排序为access_token,app_key,method,timestamp,v\n     * 1.把所有参数名和参数值进行拼接，例如：access_tokenxxxapp_keyxxxmethodxxxxxxtimestampxxxxxxvx\n     * 2.把appSecret夹在字符串的两端，例如：appSecret+XXXX+appSecret\n     * 3.使用MD5进行加密，再转化成大写\n     * link: http://open.jd.com/home/home#/doc/common?listId=890\n     * link: https://github.com/pingjiang/jd-open-api-sdk-src/blob/master/src/main/java/com/jd/open/api/sdk/DefaultJdClient.java\n     *\n     * @param appSecret 京东应用密钥\n     * @param params    签名参数\n     * @return 签名后的字符串\n     * @since 1.15.0\n     */\n    public static String generateJdSignature(String appSecret, Map<String, Object> params) {\n        Map<String, Object> treeMap = new TreeMap<>(params);\n        StringBuilder signBuilder = new StringBuilder(appSecret);\n        for (Map.Entry<String, Object> entry : treeMap.entrySet()) {\n            String name = entry.getKey();\n            String value = String.valueOf(entry.getValue());\n            if (StringUtils.isNotEmpty(name) && StringUtils.isNotEmpty(value)) {\n                signBuilder.append(name).append(value);\n            }\n        }\n        signBuilder.append(appSecret);\n        return md5(signBuilder.toString()).toUpperCase();\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/utils/HttpUtils.java",
    "content": "package me.zhyd.oauth.utils;\n\nimport com.xkcoding.http.HttpUtil;\nimport com.xkcoding.http.config.HttpConfig;\nimport com.xkcoding.http.support.HttpHeader;\nimport com.xkcoding.http.support.SimpleHttpResponse;\nimport me.zhyd.oauth.exception.AuthException;\n\nimport java.util.Map;\n\n/**\n * HttpUtil 工具，统一处理 http 请求，方便对 simple-http 做定制\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @version 1.0.0\n * @since 1.0.0\n */\npublic class HttpUtils {\n\n    private SimpleHttpResponse httpResponse;\n\n    public HttpUtils(HttpConfig config) {\n        HttpUtil.setConfig(config);\n    }\n\n    public HttpUtils() {\n    }\n\n\n    /**\n     * GET 请求\n     *\n     * @param url URL\n     * @return HttpUtils\n     */\n    public HttpUtils get(String url) {\n        this.httpResponse = HttpUtil.get(url, null, null, false);\n        return this;\n    }\n\n    /**\n     * GET 请求\n     *\n     * @param url    URL\n     * @param params 参数\n     * @param header 请求头\n     * @param encode 是否需要 url encode\n     * @return HttpUtils\n     */\n    public HttpUtils get(String url, Map<String, String> params, HttpHeader header, boolean encode) {\n        this.httpResponse = HttpUtil.get(url, params, header, encode);\n        return this;\n    }\n\n    /**\n     * POST 请求\n     *\n     * @param url URL\n     * @return HttpUtils\n     */\n    public HttpUtils post(String url) {\n        this.httpResponse = HttpUtil.post(url);\n        return this;\n    }\n\n    /**\n     * POST 请求\n     *\n     * @param url  URL\n     * @param data JSON 参数\n     * @return HttpUtils\n     */\n    public HttpUtils post(String url, String data) {\n        this.httpResponse = HttpUtil.post(url, data);\n        return this;\n    }\n\n    /**\n     * POST 请求\n     *\n     * @param url    URL\n     * @param data   JSON 参数\n     * @param header 请求头\n     * @return HttpUtils\n     */\n    public HttpUtils post(String url, String data, HttpHeader header) {\n        this.httpResponse = HttpUtil.post(url, data, header);\n        return this;\n    }\n\n    /**\n     * POST 请求\n     *\n     * @param url    URL\n     * @param params form 参数\n     * @param encode 是否需要 url encode\n     * @return HttpUtils\n     */\n    public HttpUtils post(String url, Map<String, String> params, boolean encode) {\n        this.httpResponse = HttpUtil.post(url, params, encode);\n        return this;\n    }\n\n    /**\n     * POST 请求\n     *\n     * @param url    URL\n     * @param params form 参数\n     * @param header 请求头\n     * @param encode 是否需要 url encode\n     * @return HttpUtils\n     */\n    public HttpUtils post(String url, Map<String, String> params, HttpHeader header, boolean encode) {\n        this.httpResponse = HttpUtil.post(url, params, header, encode);\n        return this;\n    }\n\n    private HttpUtils check() {\n        if (null == httpResponse) {\n            throw new AuthException(\"Invalid SimpleHttpResponse.\");\n        }\n        if (!httpResponse.isSuccess()) {\n            throw new AuthException(httpResponse.getError());\n        }\n        return this;\n    }\n\n    public String getBody() {\n        return this.check().getHttpResponse().getBody();\n    }\n\n    public SimpleHttpResponse getHttpResponse() {\n        return httpResponse;\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/utils/IpUtils.java",
    "content": "package me.zhyd.oauth.utils;\n\nimport java.net.InetAddress;\nimport java.net.UnknownHostException;\n\n/**\n * 获取IP的工具类\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.0.0\n */\npublic class IpUtils {\n\n    /**\n     * 获取IP\n     *\n     * @return ip\n     */\n    public static String getLocalIp() {\n        try {\n            return InetAddress.getLocalHost().getHostAddress();\n        } catch (UnknownHostException e) {\n            e.printStackTrace();\n            return null;\n        }\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/utils/PkceUtil.java",
    "content": "package me.zhyd.oauth.utils;\n\nimport java.nio.charset.StandardCharsets;\n\n/**\n * 该配置仅用于支持 PKCE 模式的平台，针对无服务应用，不推荐使用隐式授权，推荐使用 PKCE 模式\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @version 1.0.0\n * @since 1.0.0\n */\npublic class PkceUtil {\n\n    public static String generateCodeVerifier() {\n        String randomStr = RandomUtil.randomString(50);\n        return Base64Utils.encodeUrlSafe(randomStr);\n    }\n\n    /**\n     * 适用于 OAuth 2.0 PKCE 增强协议\n     *\n     * @param codeChallengeMethod s256 / plain\n     * @param codeVerifier        客户端生产的校验码\n     * @return code challenge\n     */\n    public static String generateCodeChallenge(String codeChallengeMethod, String codeVerifier) {\n        if (\"S256\".equalsIgnoreCase(codeChallengeMethod)) {\n            // https://tools.ietf.org/html/rfc7636#section-4.2\n            // code_challenge = BASE64URL-ENCODE(SHA256(ASCII(code_verifier)))\n            return newStringUsAscii(Base64Utils.encodeUrlSafe(Sha256.digest(codeVerifier), true));\n        } else {\n            return codeVerifier;\n        }\n    }\n\n    public static String newStringUsAscii(byte[] bytes) {\n        return new String(bytes, StandardCharsets.US_ASCII);\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/utils/RandomUtil.java",
    "content": "package me.zhyd.oauth.utils;\n\nimport java.util.concurrent.ThreadLocalRandom;\n\n/**\n * 生成随机字符串\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @version 1.0.0\n * @since 1.16.0\n */\npublic class RandomUtil {\n\n    /**\n     * 用于随机选的字符和数字\n     */\n    public static final String BASE_CHAR_NUMBER = \"abcdefghijklmnopqrstuvwxyz0123456789\";\n\n    /**\n     * 获得一个随机的字符串\n     *\n     * @param length 字符串的长度\n     * @return 指定长度的随机字符串\n     */\n    public static String randomString(int length) {\n        final StringBuilder sb = new StringBuilder(length);\n\n        if (length < 1) {\n            length = 1;\n        }\n        int baseLength = BASE_CHAR_NUMBER.length();\n        for (int i = 0; i < length; i++) {\n            int number = ThreadLocalRandom.current().nextInt(baseLength);\n            sb.append(BASE_CHAR_NUMBER.charAt(number));\n        }\n        return sb.toString();\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/utils/Sha256.java",
    "content": "package me.zhyd.oauth.utils;\n\nimport java.nio.charset.StandardCharsets;\nimport java.security.MessageDigest;\nimport java.security.NoSuchAlgorithmException;\n\n/**\n * SHA256 加密\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @version 1.0.0\n * @since 1.16.0\n */\npublic class Sha256 {\n\n    public static byte[] digest(String str) {\n        MessageDigest messageDigest;\n        try {\n            messageDigest = MessageDigest.getInstance(\"SHA-256\");\n            messageDigest.update(str.getBytes(StandardCharsets.UTF_8));\n            return messageDigest.digest();\n        } catch (NoSuchAlgorithmException e) {\n            e.printStackTrace();\n        }\n        return null;\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/utils/StringUtils.java",
    "content": "package me.zhyd.oauth.utils;\n\nimport java.nio.charset.Charset;\n\n/**\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.0.0\n */\npublic class StringUtils {\n\n    public static boolean isEmpty(String str) {\n        return null == str || str.isEmpty();\n    }\n\n    public static boolean isNotEmpty(String str) {\n        return !isEmpty(str);\n    }\n\n    /**\n     * 如果给定字符串{@code str}中不包含{@code appendStr}，则在{@code str}后追加{@code appendStr}；\n     * 如果已包含{@code appendStr}，则在{@code str}后追加{@code otherwise}\n     *\n     * @param str       给定的字符串\n     * @param appendStr 需要追加的内容\n     * @param otherwise 当{@code appendStr}不满足时追加到{@code str}后的内容\n     * @return 追加后的字符串\n     */\n    public static String appendIfNotContain(String str, String appendStr, String otherwise) {\n        if (isEmpty(str) || isEmpty(appendStr)) {\n            return str;\n        }\n        if (str.contains(appendStr)) {\n            return str.concat(otherwise);\n        }\n        return str.concat(appendStr);\n    }\n\n    /**\n     * 编码字符串\n     *\n     * @param str 字符串\n     * @param charset 字符集，如果此字段为空，则解码的结果取决于平台\n     * @return 编码后的字节码\n     */\n    public static byte[] bytes(CharSequence str, Charset charset) {\n        if (str == null) {\n            return null;\n        }\n\n        if (null == charset) {\n            return str.toString().getBytes();\n        }\n        return str.toString().getBytes(charset);\n    }\n\n    /**\n     * 解码字节码\n     *\n     * @param data 字符串\n     * @param charset 字符集，如果此字段为空，则解码的结果取决于平台\n     * @return 解码后的字符串\n     */\n    public static String str(byte[] data, Charset charset) {\n        if (data == null) {\n            return null;\n        }\n\n        if (null == charset) {\n            return new String(data);\n        }\n        return new String(data, charset);\n    }\n\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/utils/UrlBuilder.java",
    "content": "package me.zhyd.oauth.utils;\n\nimport com.xkcoding.http.util.MapUtil;\nimport com.xkcoding.http.util.StringUtil;\nimport lombok.Setter;\n\nimport java.util.Collections;\nimport java.util.LinkedHashMap;\nimport java.util.Map;\n\n/**\n * <p>\n * 构造URL\n * </p>\n *\n * @author yangkai.shen (https://xkcoding.com)\n * @since 1.9.0\n */\n@Setter\npublic class UrlBuilder {\n\n    private final Map<String, String> params = new LinkedHashMap<>(7);\n    private String baseUrl;\n\n    private UrlBuilder() {\n\n    }\n\n    /**\n     * @param baseUrl 基础路径\n     * @return the new {@code UrlBuilder}\n     */\n    public static UrlBuilder fromBaseUrl(String baseUrl) {\n        UrlBuilder builder = new UrlBuilder();\n        builder.setBaseUrl(baseUrl);\n        return builder;\n    }\n\n    /**\n     * 只读的参数Map\n     *\n     * @return unmodifiable Map\n     * @since 1.15.0\n     */\n    public Map<String, Object> getReadOnlyParams() {\n        return Collections.unmodifiableMap(params);\n    }\n\n    /**\n     * 添加参数\n     *\n     * @param key   参数名称\n     * @param value 参数值\n     * @return this UrlBuilder\n     */\n    public UrlBuilder queryParam(String key, Object value) {\n        if (StringUtil.isEmpty(key)) {\n            throw new RuntimeException(\"参数名不能为空\");\n        }\n        String valueAsString = (value != null ? value.toString() : null);\n        this.params.put(key, valueAsString);\n\n        return this;\n    }\n\n    /**\n     * 构造url\n     *\n     * @return url\n     */\n    public String build() {\n        return this.build(false);\n    }\n\n    /**\n     * 构造url\n     *\n     * @param encode 转码\n     * @return url\n     */\n    public String build(boolean encode) {\n        if (MapUtil.isEmpty(this.params)) {\n            return this.baseUrl;\n        }\n        String baseUrl = StringUtils.appendIfNotContain(this.baseUrl, \"?\", \"&\");\n        String paramString = MapUtil.parseMapToString(this.params, encode);\n        return baseUrl + paramString;\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/utils/UuidUtils.java",
    "content": "package me.zhyd.oauth.utils;\n\nimport java.nio.charset.StandardCharsets;\nimport java.util.concurrent.ThreadLocalRandom;\n\n/**\n * 高性能的创建UUID的工具类，https://github.com/lets-mica/mica\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @since 1.9.3\n */\npublic class UuidUtils {\n\n    /**\n     * All possible chars for representing a number as a String\n     * copy from mica：https://github.com/lets-mica/mica/blob/master/mica-core/src/main/java/net/dreamlu/mica/core/utils/NumberUtil.java#L113\n     */\n    private final static byte[] DIGITS = {\n        '0', '1', '2', '3', '4', '5',\n        '6', '7', '8', '9', 'a', 'b',\n        'c', 'd', 'e', 'f', 'g', 'h',\n        'i', 'j', 'k', 'l', 'm', 'n',\n        'o', 'p', 'q', 'r', 's', 't',\n        'u', 'v', 'w', 'x', 'y', 'z',\n        'A', 'B', 'C', 'D', 'E', 'F',\n        'G', 'H', 'I', 'J', 'K', 'L',\n        'M', 'N', 'O', 'P', 'Q', 'R',\n        'S', 'T', 'U', 'V', 'W', 'X',\n        'Y', 'Z'\n    };\n\n    /**\n     * 生成uuid，采用 jdk 9 的形式，优化性能\n     * copy from mica：https://github.com/lets-mica/mica/blob/master/mica-core/src/main/java/net/dreamlu/mica/core/utils/StringUtil.java#L335\n     * <p>\n     * 关于mica uuid生成方式的压测结果，可以参考：https://github.com/lets-mica/mica-jmh/wiki/uuid\n     *\n     * @return UUID\n     */\n    public static String getUUID() {\n        ThreadLocalRandom random = ThreadLocalRandom.current();\n        long lsb = random.nextLong();\n        long msb = random.nextLong();\n        byte[] buf = new byte[32];\n        formatUnsignedLong(lsb, buf, 20, 12);\n        formatUnsignedLong(lsb >>> 48, buf, 16, 4);\n        formatUnsignedLong(msb, buf, 12, 4);\n        formatUnsignedLong(msb >>> 16, buf, 8, 4);\n        formatUnsignedLong(msb >>> 32, buf, 0, 8);\n        return new String(buf, StandardCharsets.UTF_8);\n    }\n\n    /**\n     * copy from mica：https://github.com/lets-mica/mica/blob/master/mica-core/src/main/java/net/dreamlu/mica/core/utils/StringUtil.java#L348\n     */\n    private static void formatUnsignedLong(long val, byte[] buf, int offset, int len) {\n        int charPos = offset + len;\n        int radix = 1 << 4;\n        int mask = radix - 1;\n        do {\n            buf[--charPos] = DIGITS[((int) val) & mask];\n            val >>>= 4;\n        } while (charPos > offset);\n    }\n}\n"
  },
  {
    "path": "src/main/java/me/zhyd/oauth/utils/package-info.java",
    "content": "/**\n * 提供一些简单的工具和校验等\n */\npackage me.zhyd.oauth.utils;\n"
  },
  {
    "path": "src/test/java/me/zhyd/oauth/AuthRequestBuilderTest.java",
    "content": "package me.zhyd.oauth;\n\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.config.AuthExtendSource;\nimport me.zhyd.oauth.request.*;\nimport me.zhyd.oauth.utils.AuthStateUtils;\nimport org.junit.Assert;\nimport org.junit.Test;\n\npublic class AuthRequestBuilderTest {\n\n    /**\n     * 示例：一般场景下通过 AuthRequestBuilder 构建 AuthRequest\n     */\n    @Test\n    public void build2() {\n        AuthRequest authRequest = AuthRequestBuilder.builder()\n            .source(\"github\")\n            .authConfig(AuthConfig.builder()\n                .clientId(\"a\")\n                .clientSecret(\"a\")\n                .redirectUri(\"https://www.justauth.cn\")\n                .build())\n            .build();\n        Assert.assertTrue(authRequest instanceof AuthGithubRequest);\n        System.out.println(authRequest.authorize(AuthStateUtils.createState()));\n    }\n\n    /**\n     * 示例：AuthConfig 需要动态获取的场景下通过 AuthRequestBuilder 构建 AuthRequest\n     */\n    @Test\n    public void build() {\n        AuthRequest authRequest = AuthRequestBuilder.builder()\n            .source(\"gitee\")\n            .authConfig((source) -> {\n                // 通过 source 动态获取 AuthConfig\n                // 此处可以灵活的从 sql 中取配置也可以从配置文件中取配置\n                return AuthConfig.builder()\n                    .clientId(source)\n                    .clientSecret(source)\n                    .redirectUri(\"https://www.justauth.cn/\" + source)\n                    .build();\n            })\n            .build();\n        Assert.assertTrue(authRequest instanceof AuthGiteeRequest);\n        System.out.println(authRequest.authorize(AuthStateUtils.createState()));\n    }\n\n    /**\n     * 示例：自定义实现的 AuthRequest，通过 AuthRequestBuilder 构建 AuthRequest\n     */\n    @Test\n    public void build3() {\n        AuthRequest authRequest = AuthRequestBuilder.builder()\n            // 关键点：将自定义的 AuthSource 配置上\n            .extendSource(AuthExtendSource.values())\n            .source(\"other\")\n            .authConfig(AuthConfig.builder()\n                .clientId(\"a\")\n                .clientSecret(\"a\")\n                .redirectUri(\"https://www.justauth.cn\")\n                .build())\n            .build();\n        Assert.assertTrue(authRequest instanceof AuthExtendRequest);\n        System.out.println(authRequest.authorize(AuthStateUtils.createState()));\n    }\n\n    /**\n     * 测试不同平台\n     */\n    @Test\n    public void build4() {\n        AuthConfig config = AuthConfig.builder()\n            .clientId(\"a\")\n            .clientSecret(\"a\")\n            .redirectUri(\"https://www.justauth.cn\")\n            .authServerId(\"asd\")\n            .agentId(\"asd\")\n            .domainPrefix(\"asd\")\n            .stackOverflowKey(\"asd\")\n            .deviceId(\"asd\")\n            .clientOsType(3)\n            .kid(\"kid\")\n            .teamId(\"teamid\")\n            .ignoreCheckState(true)\n            .ignoreCheckRedirectUri(true)\n            .build();\n\n        for (AuthDefaultSource value : AuthDefaultSource.values()) {\n            switch (value) {\n                case TWITTER:\n                    System.out.println(value.getTargetClass());\n                    System.out.println(\"忽略 twitter\");\n                    continue;\n                case ALIPAY: {\n                    // 单独给Alipay执行测试\n                    AuthRequest authRequest = new AuthAlipayRequest(config, \"asd\");\n                    System.out.println(value.getTargetClass());\n                    System.out.println(authRequest.authorize(AuthStateUtils.createState()));\n                    continue;\n                }\n                case WECHAT_MINI_PROGRAM: {\n                    // 小程序不支持获取调用 authorize\n                    AuthRequest authRequest = new AuthWechatMiniProgramRequest(config);\n                    System.out.println(value.getTargetClass());\n                    continue;\n                }\n                case QQ_MINI_PROGRAM: {\n                    // 小程序不支持获取调用 authorize\n                    AuthRequest authRequest = new AuthQQMiniProgramRequest(config);\n                    System.out.println(value.getTargetClass());\n                    continue;\n                }\n                default:\n                    AuthRequest authRequest = AuthRequestBuilder.builder()\n                        .source(value.getName())\n                        .authConfig(config)\n                        .build();\n                    System.out.println(value.getTargetClass());\n                    System.out.println(authRequest.authorize(AuthStateUtils.createState()));\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "src/test/java/me/zhyd/oauth/cache/AuthStateCacheTest.java",
    "content": "package me.zhyd.oauth.cache;\n\nimport org.junit.Assert;\nimport org.junit.Test;\n\nimport java.util.concurrent.TimeUnit;\n\npublic class AuthStateCacheTest {\n\n    @Test\n    public void cache1() throws InterruptedException {\n        AuthDefaultStateCache.INSTANCE.cache(\"key\", \"value\");\n        Assert.assertEquals(AuthDefaultStateCache.INSTANCE.get(\"key\"), \"value\");\n\n        TimeUnit.MILLISECONDS.sleep(4);\n        Assert.assertEquals(AuthDefaultStateCache.INSTANCE.get(\"key\"), \"value\");\n    }\n\n    @Test\n    public void cache2() throws InterruptedException {\n        AuthDefaultStateCache.INSTANCE.cache(\"key\", \"value\", 10);\n        Assert.assertEquals(AuthDefaultStateCache.INSTANCE.get(\"key\"), \"value\");\n\n        // 没过期\n        TimeUnit.MILLISECONDS.sleep(5);\n        Assert.assertEquals(AuthDefaultStateCache.INSTANCE.get(\"key\"), \"value\");\n\n        // 过期\n        TimeUnit.MILLISECONDS.sleep(6);\n        Assert.assertNull(AuthDefaultStateCache.INSTANCE.get(\"key\"));\n    }\n}\n"
  },
  {
    "path": "src/test/java/me/zhyd/oauth/config/AuthExtendSource.java",
    "content": "package me.zhyd.oauth.config;\n\nimport me.zhyd.oauth.request.AuthDefaultRequest;\nimport me.zhyd.oauth.request.AuthExtendRequest;\n\n/**\n * 测试自定义实现{@link AuthSource}接口后的枚举类\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @version 1.0\n * @since 1.12.0\n */\npublic enum AuthExtendSource implements AuthSource {\n\n    OTHER {\n        /**\n         * 授权的api\n         *\n         * @return url\n         */\n        @Override\n        public String authorize() {\n            return \"http://authorize\";\n        }\n\n        /**\n         * 获取accessToken的api\n         *\n         * @return url\n         */\n        @Override\n        public String accessToken() {\n            return \"http://accessToken\";\n        }\n\n        /**\n         * 获取用户信息的api\n         *\n         * @return url\n         */\n        @Override\n        public String userInfo() {\n            return null;\n        }\n\n        /**\n         * 取消授权的api\n         *\n         * @return url\n         */\n        @Override\n        public String revoke() {\n            return null;\n        }\n\n        /**\n         * 刷新授权的api\n         *\n         * @return url\n         */\n        @Override\n        public String refresh() {\n            return null;\n        }\n\n        @Override\n        public Class<? extends AuthDefaultRequest> getTargetClass() {\n            return AuthExtendRequest.class;\n        }\n    }\n\n}\n"
  },
  {
    "path": "src/test/java/me/zhyd/oauth/log/LogTest.java",
    "content": "package me.zhyd.oauth.log;\n\nimport org.junit.Test;\n\n/**\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @version 1.0\n * @date 2019/8/2 19:36\n * @since 1.8\n */\npublic class LogTest {\n\n    public static void main(String[] args) {\n        // 测试正常打印\n        Log.debug(\"[1] This is a test.\");\n        Log.debug(\"[1] This is a test.\", new NullPointerException(\"npe\"));\n\n        Log.warn(\"[1] This is a test.\");\n        Log.warn(\"[1] This is a test.\", new NullPointerException(\"npe\"));\n\n        Log.error(\"[1] This is a test.\");\n        Log.error(\"[1] This is a test.\", new NullPointerException(\"npe\"));\n\n        // 测试只打印 error级别的日志\n        Log.Config.level = Log.Level.ERROR;\n\n        Log.debug(\"[2] This is a test.\");\n        Log.warn(\"[2] This is a test.\");\n        Log.error(\"[2] This is a test.\");\n\n        // 测试关闭日志\n        Log.Config.enable = false;\n\n        Log.debug(\"[3] This is a test.\");\n        Log.warn(\"[3] This is a test.\");\n        Log.error(\"[3] This is a test.\");\n    }\n\n    /**\n     * 1000000: 23135ms\n     * 100000: 3016ms\n     * 10000: 328ms\n     * 1000: 26ms\n     */\n    @Test\n    public void testByThread() {\n        long start = System.currentTimeMillis();\n        for (int i = 0; i < 1; i++) {\n            System.out.println(callMethodByThread());\n        }\n        long end = System.currentTimeMillis();\n        System.out.println((end - start) + \"ms\");\n\n    }\n\n    /**\n     * 1000000: 19058ms\n     * 100000: 2772ms\n     * 10000: 323ms\n     * 1000: 29ms\n     */\n    @Test\n    public void testByThrowable() {\n        long end = System.currentTimeMillis();\n        for (int i = 0; i < 1; i++) {\n            System.out.println(callMethodByThrowable());\n        }\n        long end2 = System.currentTimeMillis();\n        System.out.println((end2 - end) + \"ms\");\n\n    }\n\n    @Test\n    public void testBySecurityManager() {\n        long end = System.currentTimeMillis();\n        for (int i = 0; i < 1; i++) {\n            System.out.println(callMethodBySecurityManager());\n        }\n        long end2 = System.currentTimeMillis();\n        System.out.println((end2 - end) + \"ms\");\n\n    }\n\n    private String callMethodByThread() {\n        StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();\n        for (StackTraceElement stackTraceElement : stackTrace) {\n            System.out.println(stackTraceElement.getMethodName());\n        }\n        return stackTrace[2].getMethodName();\n    }\n\n    private String callMethodByThrowable() {\n        StackTraceElement[] stackTrace = (new Throwable()).getStackTrace();\n        for (StackTraceElement stackTraceElement : stackTrace) {\n            System.out.println(stackTraceElement.getMethodName());\n        }\n        return stackTrace[2].getMethodName();\n    }\n\n    private String callMethodBySecurityManager() {\n        return new SecurityManager() {\n            String getClassName() {\n                for (Class clazz : getClassContext()) {\n                    System.out.println(clazz);\n                }\n                return getClassContext()[0].getName();\n            }\n        }.getClassName();\n    }\n\n}\n"
  },
  {
    "path": "src/test/java/me/zhyd/oauth/model/AuthUserTest.java",
    "content": "package me.zhyd.oauth.model;\n\nimport com.alibaba.fastjson.JSON;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.config.AuthExtendSource;\nimport me.zhyd.oauth.config.AuthSource;\nimport org.junit.Assert;\nimport org.junit.Test;\n\npublic class AuthUserTest {\n\n    @Test\n    public void serialize() {\n\n        AuthUser user = AuthUser.builder()\n            .nickname(\"test\")\n            .build();\n        String json = JSON.toJSONString(user);\n        Assert.assertEquals(json, \"{\\\"nickname\\\":\\\"test\\\",\\\"snapshotUser\\\":false}\");\n\n    }\n\n    @Test\n    public void deserialize() {\n        AuthUser user = AuthUser.builder()\n            .nickname(\"test\")\n            .build();\n        String json = JSON.toJSONString(user);\n\n        AuthUser deserializeUser = JSON.parseObject(json, AuthUser.class);\n        Assert.assertEquals(deserializeUser.getNickname(), \"test\");\n    }\n\n    @Test\n    public void source() {\n        AuthSource source = AuthDefaultSource.HUAWEI;\n        AuthUser user = AuthUser.builder()\n            .source(source.toString())\n            .build();\n        Assert.assertEquals(user.getSource(), \"HUAWEI\");\n\n        source = AuthExtendSource.OTHER;\n        user = AuthUser.builder()\n            .source(source.toString())\n            .build();\n        Assert.assertEquals(user.getSource(), \"OTHER\");\n\n        source = AuthDefaultSource.HUAWEI;\n        Assert.assertEquals(source, AuthDefaultSource.HUAWEI);\n\n        source = AuthExtendSource.OTHER;\n        Assert.assertEquals(source, AuthExtendSource.OTHER);\n    }\n\n}\n"
  },
  {
    "path": "src/test/java/me/zhyd/oauth/request/AuthExtendRequest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport me.zhyd.oauth.cache.AuthStateCache;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthExtendSource;\nimport me.zhyd.oauth.enums.AuthResponseStatus;\nimport me.zhyd.oauth.enums.AuthUserGender;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthResponse;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\n\n/**\n * 测试用自定义扩展的第三方request\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @version 1.0\n * @since 1.12.0\n */\npublic class AuthExtendRequest extends AuthDefaultRequest {\n\n    public AuthExtendRequest(AuthConfig config) {\n        super(config, AuthExtendSource.OTHER);\n    }\n\n    public AuthExtendRequest(AuthConfig config, AuthStateCache authStateCache) {\n        super(config, AuthExtendSource.OTHER, authStateCache);\n    }\n\n    /**\n     * 获取access token\n     *\n     * @param authCallback 授权成功后的回调参数\n     * @return token\n     * @see AuthDefaultRequest#authorize()\n     * @see AuthDefaultRequest#authorize(String)\n     */\n    @Override\n    public AuthToken getAccessToken(AuthCallback authCallback) {\n        return AuthToken.builder()\n            .openId(\"openId\")\n            .expireIn(1000)\n            .idToken(\"idToken\")\n            .scope(\"scope\")\n            .refreshToken(\"refreshToken\")\n            .accessToken(\"accessToken\")\n            .code(\"code\")\n            .build();\n    }\n\n    /**\n     * 使用token换取用户信息\n     *\n     * @param authToken token信息\n     * @return 用户信息\n     * @see AuthDefaultRequest#getAccessToken(AuthCallback)\n     */\n    @Override\n    public AuthUser getUserInfo(AuthToken authToken) {\n        return AuthUser.builder()\n            .username(\"test\")\n            .nickname(\"test\")\n            .gender(AuthUserGender.MALE)\n            .token(authToken)\n            .source(this.source.toString())\n            .build();\n    }\n\n    /**\n     * 撤销授权\n     *\n     * @param authToken 登录成功后返回的Token信息\n     * @return AuthResponse\n     */\n    @Override\n    public AuthResponse revoke(AuthToken authToken) {\n        return AuthResponse.builder()\n            .code(AuthResponseStatus.SUCCESS.getCode())\n            .msg(AuthResponseStatus.SUCCESS.getMsg())\n            .build();\n    }\n\n    /**\n     * 刷新access token （续期）\n     *\n     * @param authToken 登录成功后返回的Token信息\n     * @return AuthResponse\n     */\n    @Override\n    public AuthResponse<AuthToken> refresh(AuthToken authToken) {\n        return AuthResponse.<AuthToken>builder()\n            .code(AuthResponseStatus.SUCCESS.getCode())\n            .data(AuthToken.builder()\n                .openId(\"openId\")\n                .expireIn(1000)\n                .idToken(\"idToken\")\n                .scope(\"scope\")\n                .refreshToken(\"refreshToken\")\n                .accessToken(\"accessToken\")\n                .code(\"code\")\n                .build())\n            .build();\n    }\n}\n"
  },
  {
    "path": "src/test/java/me/zhyd/oauth/request/AuthExtendRequestTest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport com.alibaba.fastjson.JSON;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthResponse;\nimport me.zhyd.oauth.model.AuthToken;\nimport me.zhyd.oauth.model.AuthUser;\nimport me.zhyd.oauth.utils.AuthStateUtils;\nimport org.junit.Assert;\nimport org.junit.Test;\n\n/**\n * 自定义扩展的第三方request的测试类，用于演示具体的用法\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @version 1.0\n * @since 1.12.0\n */\npublic class AuthExtendRequestTest {\n\n    @Test\n    public void authorize() {\n        AuthRequest request = new AuthExtendRequest(AuthConfig.builder()\n            .clientId(\"clientId\")\n            .clientSecret(\"clientSecret\")\n            .redirectUri(\"http://redirectUri\")\n            .build());\n        String authorize = request.authorize(AuthStateUtils.createState());\n        System.out.println(authorize);\n        Assert.assertNotNull(authorize);\n    }\n\n    @Test\n    public void login() {\n        AuthRequest request = new AuthExtendRequest(AuthConfig.builder()\n            .clientId(\"clientId\")\n            .clientSecret(\"clientSecret\")\n            .redirectUri(\"http://redirectUri\")\n            .build());\n\n        String state = AuthStateUtils.createState();\n        request.authorize(state);\n        AuthCallback callback = AuthCallback.builder()\n            .code(\"code\")\n            .state(state)\n            .build();\n        AuthResponse<AuthUser> response = request.login(callback);\n        Assert.assertNotNull(response);\n\n        AuthUser user = response.getData();\n        Assert.assertNotNull(user);\n        System.out.println(JSON.toJSONString(user));\n    }\n\n    @Test\n    public void revoke() {\n        AuthRequest request = new AuthExtendRequest(AuthConfig.builder()\n            .clientId(\"clientId\")\n            .clientSecret(\"clientSecret\")\n            .redirectUri(\"http://redirectUri\")\n            .build());\n\n        AuthResponse response = request.revoke(AuthToken.builder().build());\n        Assert.assertNotNull(response);\n        System.out.println(JSON.toJSONString(response));\n    }\n\n    @Test\n    public void refresh() {\n        AuthRequest request = new AuthExtendRequest(AuthConfig.builder()\n            .clientId(\"clientId\")\n            .clientSecret(\"clientSecret\")\n            .redirectUri(\"http://redirectUri\")\n            .build());\n\n        AuthResponse<AuthToken> response = request.refresh(AuthToken.builder().build());\n        Assert.assertNotNull(response);\n        System.out.println(JSON.toJSONString(response.getData()));\n\n    }\n}\n"
  },
  {
    "path": "src/test/java/me/zhyd/oauth/request/AuthWeChatEnterpriseWebRequestTest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.utils.AuthStateUtils;\nimport org.junit.Test;\n\nimport static org.junit.Assert.*;\n\npublic class AuthWeChatEnterpriseWebRequestTest {\n\n    @Test\n    public void authorize() {\n        AuthRequest request = new AuthWeChatEnterpriseWebRequest(AuthConfig.builder()\n            .clientId(\"a\")\n            .clientSecret(\"a\")\n            .redirectUri(\"https://www.justauth.cn\")\n            .build());\n        System.out.println(request.authorize(AuthStateUtils.createState()));\n    }\n}\n"
  },
  {
    "path": "src/test/java/me/zhyd/oauth/request/AuthWeChatMpRequestTest.java",
    "content": "package me.zhyd.oauth.request;\n\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.utils.AuthStateUtils;\nimport org.junit.Test;\n\npublic class AuthWeChatMpRequestTest {\n\n    @Test\n    public void authorize() {\n\n        AuthRequest request = new AuthWeChatMpRequest(AuthConfig.builder()\n            .clientId(\"a\")\n            .clientSecret(\"a\")\n            .redirectUri(\"https://www.justauth.cn\")\n            .build());\n        System.out.println(request.authorize(AuthStateUtils.createState()));\n    }\n}\n"
  },
  {
    "path": "src/test/java/me/zhyd/oauth/utils/GlobalAuthUtilsTest.java",
    "content": "package me.zhyd.oauth.utils;\n\nimport com.alibaba.fastjson.JSON;\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.model.AuthCallback;\nimport me.zhyd.oauth.model.AuthToken;\nimport org.junit.Assert;\nimport org.junit.Test;\n\nimport java.util.HashMap;\nimport java.util.Map;\nimport java.util.TreeMap;\n\nimport static me.zhyd.oauth.config.AuthDefaultSource.TWITTER;\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertNotNull;\n\npublic class GlobalAuthUtilsTest {\n\n    @Test\n    public void generateDingTalkSignature() {\n        assertEquals(\"mLTZEMqIlpAA3xtJ43KcRT0EDLwgSamFe%2FNis5lq9ik%3D\", GlobalAuthUtils.generateDingTalkSignature(\"SHA-256\", \"1562325753000 \"));\n    }\n\n    @Test\n    public void urlDecode() {\n        assertEquals(\"\", GlobalAuthUtils.urlDecode(null));\n        assertEquals(\"https://www.foo.bar\", GlobalAuthUtils.urlDecode(\"https://www.foo.bar\"));\n        assertEquals(\"mLTZEMqIlpAA3xtJ43KcRT0EDLwgSamFe/Nis5lq9ik=\", GlobalAuthUtils.urlDecode(\"mLTZEMqIlpAA3xtJ43KcRT0EDLwgSamFe%2FNis5lq9ik%3D\"));\n    }\n\n    @Test\n    public void parseStringToMap() {\n        Map expected = new HashMap();\n        expected.put(\"bar\", \"baz\");\n        assertEquals(expected, GlobalAuthUtils.parseStringToMap(\"foo&bar=baz\"));\n    }\n\n    @Test\n    public void isHttpProtocol() {\n        Assert.assertFalse(GlobalAuthUtils.isHttpProtocol(\"\"));\n        Assert.assertFalse(GlobalAuthUtils.isHttpProtocol(\"foo\"));\n\n        Assert.assertTrue(GlobalAuthUtils.isHttpProtocol(\"http://www.foo.bar\"));\n    }\n\n    @Test\n    public void isHttpsProtocol() {\n        Assert.assertFalse(GlobalAuthUtils.isHttpsProtocol(\"\"));\n        Assert.assertFalse(GlobalAuthUtils.isHttpsProtocol(\"foo\"));\n\n        Assert.assertTrue(GlobalAuthUtils.isHttpsProtocol(\"https://www.foo.bar\"));\n    }\n\n    @Test\n    public void isLocalHost() {\n        Assert.assertFalse(GlobalAuthUtils.isLocalHost(\"foo\"));\n\n        Assert.assertTrue(GlobalAuthUtils.isLocalHost(\"\"));\n        Assert.assertTrue(GlobalAuthUtils.isLocalHost(\"127.0.0.1\"));\n        Assert.assertTrue(GlobalAuthUtils.isLocalHost(\"localhost\"));\n    }\n\n    @Test\n    public void testGenerateTwitterSignatureForRequestToken() {\n        AuthConfig config = AuthConfig.builder()\n            .clientId(\"HD0XLqzi5Wz0G08rh45Cg8mgh\")\n            .clientSecret(\"0YX3RH2DnPiT77pgzLzFdfpMKX8ENLIWQKYQ7lG5TERuZNgXN5\")\n            .redirectUri(\"https://codinglife.tech\")\n            .build();\n        Map<String, String> params = new HashMap<>();\n        params.put(\"oauth_consumer_key\", config.getClientId());\n        params.put(\"oauth_nonce\", \"sTj7Ivg73u052eXstpoS1AWQCynuDEPN\");\n        params.put(\"oauth_signature_method\", \"HMAC-SHA1\");\n        params.put(\"oauth_timestamp\", \"1569750981\");\n        params.put(\"oauth_callback\", config.getRedirectUri());\n        params.put(\"oauth_version\", \"1.0\");\n\n        String baseUrl = \"https://api.twitter.com/oauth/request_token\";\n        params.put(\"oauth_signature\", GlobalAuthUtils.generateTwitterSignature(params, \"POST\", baseUrl, config.getClientSecret(), null));\n\n        params.forEach((k, v) -> params.put(k, \"\\\"\" + GlobalAuthUtils.urlEncode(v) + \"\\\"\"));\n        String actual = \"OAuth \" + GlobalAuthUtils.parseMapToString(params, false).replaceAll(\"&\", \", \");\n\n        assertEquals(\"OAuth oauth_nonce=\\\"sTj7Ivg73u052eXstpoS1AWQCynuDEPN\\\", oauth_signature=\\\"%2BL5Jq%2FTaKubge04cWw%2B4yfjFlaU%3D\\\", oauth_callback=\\\"https%3A%2F%2Fcodinglife.tech\\\", oauth_consumer_key=\\\"HD0XLqzi5Wz0G08rh45Cg8mgh\\\", oauth_signature_method=\\\"HMAC-SHA1\\\", oauth_timestamp=\\\"1569750981\\\", oauth_version=\\\"1.0\\\"\", actual);\n    }\n\n    @Test\n    public void testGenerateTwitterSignatureForAccessToken() {\n        AuthConfig config = AuthConfig.builder()\n            .clientId(\"HD0XLqzi5Wz0G08rh45Cg8mgh\")\n            .clientSecret(\"0YX3RH2DnPiT77pgzLzFdfpMKX8ENLIWQKYQ7lG5TERuZNgXN5\")\n            .build();\n        AuthCallback authCallback = AuthCallback.builder()\n            .oauth_token(\"W_KLmAAAAAAAxq5LAAABbXxJeD0\")\n            .oauth_verifier(\"lYou4gxfA6S5KioUa8VF8HCShzA2nSxp\")\n            .build();\n        Map<String, String> params = new HashMap<>();\n        params.put(\"oauth_consumer_key\", config.getClientId());\n        params.put(\"oauth_nonce\", \"sTj7Ivg73u052eXstpoS1AWQCynuDEPN\");\n        params.put(\"oauth_signature_method\", \"HMAC-SHA1\");\n        params.put(\"oauth_timestamp\", \"1569751082\");\n        params.put(\"oauth_token\", authCallback.getOauth_token());\n        params.put(\"oauth_verifier\", authCallback.getOauth_verifier());\n        params.put(\"oauth_version\", \"1.0\");\n\n        params.put(\"oauth_signature\", GlobalAuthUtils.generateTwitterSignature(params, \"POST\", TWITTER.accessToken(), config.getClientSecret(), authCallback\n            .getOauth_token()));\n\n        params.forEach((k, v) -> params.put(k, \"\\\"\" + GlobalAuthUtils.urlEncode(v) + \"\\\"\"));\n        String actual = \"OAuth \" + GlobalAuthUtils.parseMapToString(params, false).replaceAll(\"&\", \", \");\n\n        assertEquals(\"OAuth oauth_verifier=\\\"lYou4gxfA6S5KioUa8VF8HCShzA2nSxp\\\", oauth_nonce=\\\"sTj7Ivg73u052eXstpoS1AWQCynuDEPN\\\", oauth_signature=\\\"9i0lmWgvphtkl2KcCO9VyZ3K2%2F0%3D\\\", oauth_token=\\\"W_KLmAAAAAAAxq5LAAABbXxJeD0\\\", oauth_consumer_key=\\\"HD0XLqzi5Wz0G08rh45Cg8mgh\\\", oauth_signature_method=\\\"HMAC-SHA1\\\", oauth_timestamp=\\\"1569751082\\\", oauth_version=\\\"1.0\\\"\", actual);\n    }\n\n    @Test\n    public void testGenerateTwitterSignatureForUserInfo() {\n        AuthConfig config = AuthConfig.builder()\n            .clientId(\"HD0XLqzi5Wz0G08rh45Cg8mgh\")\n            .clientSecret(\"0YX3RH2DnPiT77pgzLzFdfpMKX8ENLIWQKYQ7lG5TERuZNgXN5\")\n            .build();\n        AuthToken authToken = AuthToken.builder()\n            .oauthToken(\"1961977975-PcFQaCnpN9h9xqtqHwHlpGBXFrHJ9bOLy7OtGAL\")\n            .oauthTokenSecret(\"ffyKe39GYYf8tAyhliSe3QmazpO65kZp5b49xOFX6wHho\")\n            .userId(\"1961977975\")\n            .screenName(\"pengisgood\")\n            .build();\n\n        Map<String, String> oauthParams = new HashMap<>();\n        oauthParams.put(\"oauth_consumer_key\", config.getClientId());\n        oauthParams.put(\"oauth_nonce\", \"sTj7Ivg73u052eXstpoS1AWQCynuDEPN\");\n        oauthParams.put(\"oauth_signature_method\", \"HMAC-SHA1\");\n        oauthParams.put(\"oauth_timestamp\", \"1569751082\");\n        oauthParams.put(\"oauth_token\", authToken.getOauthToken());\n        oauthParams.put(\"oauth_version\", \"1.0\");\n\n        Map<String, String> queryParams = new HashMap<>();\n        queryParams.put(\"user_id\", authToken.getUserId());\n        queryParams.put(\"screen_name\", authToken.getScreenName());\n        queryParams.put(\"include_entities\", Boolean.toString(true));\n\n        Map<String, String> params = new HashMap<>(queryParams);\n        oauthParams.put(\"oauth_signature\", GlobalAuthUtils.generateTwitterSignature(params, \"GET\", TWITTER.userInfo(), config.getClientSecret(), authToken\n            .getOauthTokenSecret()));\n        oauthParams.forEach((k, v) -> oauthParams.put(k, \"\\\"\" + GlobalAuthUtils.urlEncode(v) + \"\\\"\"));\n\n        String actual = \"OAuth \" + GlobalAuthUtils.parseMapToString(oauthParams, false).replaceAll(\"&\", \", \");\n        assertEquals(\"OAuth oauth_nonce=\\\"sTj7Ivg73u052eXstpoS1AWQCynuDEPN\\\", oauth_signature=\\\"OsqHjRmBf7syxlz8lB7MRdzqEjY%3D\\\", oauth_token=\\\"1961977975-PcFQaCnpN9h9xqtqHwHlpGBXFrHJ9bOLy7OtGAL\\\", oauth_consumer_key=\\\"HD0XLqzi5Wz0G08rh45Cg8mgh\\\", oauth_signature_method=\\\"HMAC-SHA1\\\", oauth_timestamp=\\\"1569751082\\\", oauth_version=\\\"1.0\\\"\", actual);\n    }\n\n    @Test\n    public void md5() {\n        String str = \"helloworld,iamjustauth\";\n        String md5Str = GlobalAuthUtils.md5(str);\n        assertEquals(\"b0d923de4289b69976448cac718528b8\", md5Str);\n    }\n\n    @Test\n    public void treemap() {\n        Map<String, Object> parameters = new HashMap<>();\n        parameters.put(\"user_id\", \"1\");\n        parameters.put(\"screen_name\", \"222\");\n        parameters.put(\"a\", \"222\");\n        parameters.put(\"include_entities\", Boolean.toString(true));\n        final Map<String, Object> sorted = new TreeMap<>(parameters);\n        assertEquals(\"{\\\"a\\\":\\\"222\\\",\\\"include_entities\\\":\\\"true\\\",\\\"screen_name\\\":\\\"222\\\",\\\"user_id\\\":\\\"1\\\"}\", JSON.toJSONString(sorted));\n    }\n\n    @Test\n    public void urlEncode() {\n        assertEquals(\"\", GlobalAuthUtils.urlEncode(null));\n        assertEquals(\"https%3A%2F%2Fwww.foo.bar\", GlobalAuthUtils.urlEncode(\"https://www.foo.bar\"));\n        assertEquals(\"mLTZEMqIlpAA3xtJ43KcRT0EDLwgSamFe%252FNis5lq9ik%253D\", GlobalAuthUtils.urlEncode(\"mLTZEMqIlpAA3xtJ43KcRT0EDLwgSamFe%2FNis5lq9ik%3D\"));\n    }\n\n    @Test\n    public void parseMapToString() {\n        Map<String, String> parameters = new HashMap<>();\n        parameters.put(\"user_id\", \"1\");\n        parameters.put(\"screen_name\", \"史上最全的第三方授权登录库\");\n        parameters.put(\"include_entities\", Boolean.toString(true));\n        assertEquals(\"user_id=1&screen_name=史上最全的第三方授权登录库&include_entities=true\", GlobalAuthUtils.parseMapToString(parameters, false));\n        assertEquals(\"user_id=1&screen_name=%E5%8F%B2%E4%B8%8A%E6%9C%80%E5%85%A8%E7%9A%84%E7%AC%AC%E4%B8%89%E6%96%B9%E6%8E%88%E6%9D%83%E7%99%BB%E5%BD%95%E5%BA%93&include_entities=true\", GlobalAuthUtils.parseMapToString(parameters, true));\n        assertEquals(\"\", GlobalAuthUtils.parseMapToString(null, true));\n    }\n\n    @Test\n    public void generateNonce() {\n        assertEquals(10, GlobalAuthUtils.generateNonce(10).length());\n    }\n\n    @Test\n    public void getTimestamp() {\n        assertNotNull(GlobalAuthUtils.getTimestamp());\n    }\n\n    @Test\n    public void generateTwitterSignature() {\n        Map<String, String> queryParams = new HashMap<>();\n        queryParams.put(\"name\", \"你好\");\n        queryParams.put(\"gender\", \"male\");\n\n        assertEquals(\"20FYnV2aZnxNQtp+I0tpMRTvcx0=\", GlobalAuthUtils.generateTwitterSignature(queryParams, \"GET\", TWITTER.userInfo(), \"xxxxx\", \"xxxxx\"));\n    }\n\n    @Test\n    public void generateElemeSignature() {\n        Map<String, Object> parameters = new HashMap<>();\n        parameters.put(\"name\", \"你好\");\n        parameters.put(\"gender\", \"male\");\n\n        String appKey = \"appKey\";\n        String secret = \"appKey\";\n        long timestamp = 1233456789;\n        String action = \"appKey\";\n        String token = \"appKey\";\n\n        assertEquals(\"26FEB8BF7E84FED2619D9C5D97F421BD\", GlobalAuthUtils.generateElemeSignature(appKey, secret, timestamp, action, token, parameters));\n    }\n\n    @Test\n    public void generateJdSignature() {\n        Map<String, Object> parameters = new HashMap<>();\n        parameters.put(\"name\", \"你好\");\n        parameters.put(\"gender\", \"male\");\n\n        String appSecret = \"appKey\";\n\n        assertEquals(\"FE04EC03BA8A619802CF309959C2B43F\", GlobalAuthUtils.generateJdSignature(appSecret, parameters));\n    }\n}\n"
  },
  {
    "path": "src/test/java/me/zhyd/oauth/utils/JsonPathTest.java",
    "content": "package me.zhyd.oauth.utils;\n\nimport com.alibaba.fastjson.JSON;\nimport com.alibaba.fastjson.JSONObject;\nimport com.alibaba.fastjson.JSONPath;\nimport org.junit.Assert;\nimport org.junit.Test;\n\nimport java.util.ArrayList;\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\n\n/**\n * JsonPath用法测试\n *\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n */\npublic class JsonPathTest {\n\n    @Test\n    public void jsonPath() {\n        List<Map<String, Map<String, Object>>> list = new ArrayList<>();\n\n        Map<String, Map<String, Object>> map = new HashMap<>();\n        Map<String, Object> node = new HashMap<>();\n        node.put(\"emailAddress\", \"xxxx\");\n        map.put(\"handle~\", node);\n        list.add(map);\n\n\n        Map<String, Object> master = new HashMap<>();\n        master.put(\"elements\", list);\n        JSONObject emailObj = JSONObject.parseObject(JSON.toJSONString(master));\n        Object object = JSONPath.eval(emailObj, \"$['elements'][0]['handle~']['emailAddress']\");\n        Assert.assertEquals(\"xxxx\", object);\n    }\n}\n"
  },
  {
    "path": "src/test/java/me/zhyd/oauth/utils/ScopeTest.java",
    "content": "package me.zhyd.oauth.utils;\n\nimport org.junit.Test;\n\nimport java.util.Arrays;\nimport java.util.Comparator;\nimport java.util.List;\nimport java.util.stream.Collectors;\n\n/**\n * @author yadong.zhang (yadong.zhang0415(a)gmail.com)\n * @version 1.0.0\n * @date 2020/7/3 16:06\n * @since 1.0.0\n */\npublic class ScopeTest {\n\n    @Test\n    public void googleScope() {\n        String scopeStr = \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform.read-only(\\\"https://www.googleapis.com/auth/cloud-platform.read-only\\\", \\\"View your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"adexchange.buyer(\\\"https://www.googleapis.com/auth/adexchange.buyer\\\", \\\"Manage your Ad Exchange buyer account configuration\\\"),\\n\" +\n            \"adexchange.buyer(\\\"https://www.googleapis.com/auth/adexchange.buyer\\\", \\\"Manage your Ad Exchange buyer account configuration\\\"),\\n\" +\n            \"adsensehost(\\\"https://www.googleapis.com/auth/adsensehost\\\", \\\"View and manage your AdSense host data and associated accounts\\\"),\\n\" +\n            \"adsense(\\\"https://www.googleapis.com/auth/adsense\\\", \\\"View and manage your AdSense data\\\"),\\n\" +\n            \"adsense.readonly(\\\"https://www.googleapis.com/auth/adsense.readonly\\\", \\\"View your AdSense data\\\"),\\n\" +\n            \"admin.datatransfer(\\\"https://www.googleapis.com/auth/admin.datatransfer\\\", \\\"View and manage data transfers between users in your organization\\\"),\\n\" +\n            \"admin.datatransfer.readonly(\\\"https://www.googleapis.com/auth/admin.datatransfer.readonly\\\", \\\"View data transfers between users in your organization\\\"),\\n\" +\n            \"admin.directory.customer(\\\"https://www.googleapis.com/auth/admin.directory.customer\\\", \\\"View and manage customer related information\\\"),\\n\" +\n            \"admin.directory.customer.readonly(\\\"https://www.googleapis.com/auth/admin.directory.customer.readonly\\\", \\\"View customer related information\\\"),\\n\" +\n            \"admin.directory.device.chromeos(\\\"https://www.googleapis.com/auth/admin.directory.device.chromeos\\\", \\\"View and manage your Chrome OS devices' metadata\\\"),\\n\" +\n            \"admin.directory.device.chromeos.readonly(\\\"https://www.googleapis.com/auth/admin.directory.device.chromeos.readonly\\\", \\\"View your Chrome OS devices' metadata\\\"),\\n\" +\n            \"admin.directory.device.mobile(\\\"https://www.googleapis.com/auth/admin.directory.device.mobile\\\", \\\"View and manage your mobile devices' metadata\\\"),\\n\" +\n            \"admin.directory.device.mobile.action(\\\"https://www.googleapis.com/auth/admin.directory.device.mobile.action\\\", \\\"Manage your mobile devices by performing administrative tasks\\\"),\\n\" +\n            \"admin.directory.device.mobile.readonly(\\\"https://www.googleapis.com/auth/admin.directory.device.mobile.readonly\\\", \\\"View your mobile devices' metadata\\\"),\\n\" +\n            \"admin.directory.domain(\\\"https://www.googleapis.com/auth/admin.directory.domain\\\", \\\"View and manage the provisioning of domains for your customers\\\"),\\n\" +\n            \"admin.directory.domain.readonly(\\\"https://www.googleapis.com/auth/admin.directory.domain.readonly\\\", \\\"View domains related to your customers\\\"),\\n\" +\n            \"admin.directory.group(\\\"https://www.googleapis.com/auth/admin.directory.group\\\", \\\"View and manage the provisioning of groups on your domain\\\"),\\n\" +\n            \"admin.directory.group.member(\\\"https://www.googleapis.com/auth/admin.directory.group.member\\\", \\\"View and manage group subscriptions on your domain\\\"),\\n\" +\n            \"admin.directory.group.member.readonly(\\\"https://www.googleapis.com/auth/admin.directory.group.member.readonly\\\", \\\"View group subscriptions on your domain\\\"),\\n\" +\n            \"admin.directory.group.readonly(\\\"https://www.googleapis.com/auth/admin.directory.group.readonly\\\", \\\"View groups on your domain\\\"),\\n\" +\n            \"admin.directory.notifications(\\\"https://www.googleapis.com/auth/admin.directory.notifications\\\", \\\"View and manage notifications received on your domain\\\"),\\n\" +\n            \"admin.directory.orgunit(\\\"https://www.googleapis.com/auth/admin.directory.orgunit\\\", \\\"View and manage organization units on your domain\\\"),\\n\" +\n            \"admin.directory.orgunit.readonly(\\\"https://www.googleapis.com/auth/admin.directory.orgunit.readonly\\\", \\\"View organization units on your domain\\\"),\\n\" +\n            \"admin.directory.resource.calendar(\\\"https://www.googleapis.com/auth/admin.directory.resource.calendar\\\", \\\"View and manage the provisioning of calendar resources on your domain\\\"),\\n\" +\n            \"admin.directory.resource.calendar.readonly(\\\"https://www.googleapis.com/auth/admin.directory.resource.calendar.readonly\\\", \\\"View calendar resources on your domain\\\"),\\n\" +\n            \"admin.directory.rolemanagement(\\\"https://www.googleapis.com/auth/admin.directory.rolemanagement\\\", \\\"Manage delegated admin roles for your domain\\\"),\\n\" +\n            \"admin.directory.rolemanagement.readonly(\\\"https://www.googleapis.com/auth/admin.directory.rolemanagement.readonly\\\", \\\"View delegated admin roles for your domain\\\"),\\n\" +\n            \"admin.directory.user(\\\"https://www.googleapis.com/auth/admin.directory.user\\\", \\\"View and manage the provisioning of users on your domain\\\"),\\n\" +\n            \"admin.directory.user.alias(\\\"https://www.googleapis.com/auth/admin.directory.user.alias\\\", \\\"View and manage user aliases on your domain\\\"),\\n\" +\n            \"admin.directory.user.alias.readonly(\\\"https://www.googleapis.com/auth/admin.directory.user.alias.readonly\\\", \\\"View user aliases on your domain\\\"),\\n\" +\n            \"admin.directory.user.readonly(\\\"https://www.googleapis.com/auth/admin.directory.user.readonly\\\", \\\"View users on your domain\\\"),\\n\" +\n            \"admin.directory.user.security(\\\"https://www.googleapis.com/auth/admin.directory.user.security\\\", \\\"Manage data access permissions for users on your domain\\\"),\\n\" +\n            \"admin.directory.userschema(\\\"https://www.googleapis.com/auth/admin.directory.userschema\\\", \\\"View and manage the provisioning of user schemas on your domain\\\"),\\n\" +\n            \"admin.directory.userschema.readonly(\\\"https://www.googleapis.com/auth/admin.directory.userschema.readonly\\\", \\\"View user schemas on your domain\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"admin.reports.audit.readonly(\\\"https://www.googleapis.com/auth/admin.reports.audit.readonly\\\", \\\"View audit reports for your G Suite domain\\\"),\\n\" +\n            \"admin.reports.usage.readonly(\\\"https://www.googleapis.com/auth/admin.reports.usage.readonly\\\", \\\"View usage reports for your G Suite domain\\\"),\\n\" +\n            \"analytics(\\\"https://www.googleapis.com/auth/analytics\\\", \\\"View and manage your Google Analytics data\\\"),\\n\" +\n            \"analytics.readonly(\\\"https://www.googleapis.com/auth/analytics.readonly\\\", \\\"View your Google Analytics data\\\"),\\n\" +\n            \"androidmanagement(\\\"https://www.googleapis.com/auth/androidmanagement\\\", \\\"Manage Android devices and apps for your customers\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"appengine.admin(\\\"https://www.googleapis.com/auth/appengine.admin\\\", \\\"View and manage your applications deployed on Google App Engine\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform.read-only(\\\"https://www.googleapis.com/auth/cloud-platform.read-only\\\", \\\"View your data across Google Cloud Platform services\\\"),\\n\" +\n            \"(\\\"https://mail.google.com/\\\", \\\"Read, compose, send, and permanently delete all your email from Gmail\\\"),\\n\" +\n            \"feeds(\\\"https://www.google.com/calendar/feeds\\\", \\\"See, edit, share, and permanently delete all the calendars you can access using Google Calendar\\\"),\\n\" +\n            \"feeds(\\\"https://www.google.com/m8/feeds\\\", \\\"See, edit, download, and permanently delete your contacts\\\"),\\n\" +\n            \"admin.directory.group(\\\"https://www.googleapis.com/auth/admin.directory.group\\\", \\\"View and manage the provisioning of groups on your domain\\\"),\\n\" +\n            \"admin.directory.user(\\\"https://www.googleapis.com/auth/admin.directory.user\\\", \\\"View and manage the provisioning of users on your domain\\\"),\\n\" +\n            \"documents(\\\"https://www.googleapis.com/auth/documents\\\", \\\"View and manage your Google Docs documents\\\"),\\n\" +\n            \"drive(\\\"https://www.googleapis.com/auth/drive\\\", \\\"See, edit, create, and delete all of your Google Drive files\\\"),\\n\" +\n            \"forms(\\\"https://www.googleapis.com/auth/forms\\\", \\\"View and manage your forms in Google Drive\\\"),\\n\" +\n            \"forms.currentonly(\\\"https://www.googleapis.com/auth/forms.currentonly\\\", \\\"View and manage forms that this application has been installed in\\\"),\\n\" +\n            \"groups(\\\"https://www.googleapis.com/auth/groups\\\", \\\"View and manage your Google Groups\\\"),\\n\" +\n            \"script.deployments(\\\"https://www.googleapis.com/auth/script.deployments\\\", \\\"Create and update Google Apps Script deployments\\\"),\\n\" +\n            \"script.deployments.readonly(\\\"https://www.googleapis.com/auth/script.deployments.readonly\\\", \\\"View Google Apps Script deployments\\\"),\\n\" +\n            \"script.metrics(\\\"https://www.googleapis.com/auth/script.metrics\\\", \\\"View Google Apps Script project's metrics\\\"),\\n\" +\n            \"script.processes(\\\"https://www.googleapis.com/auth/script.processes\\\", \\\"View Google Apps Script processes\\\"),\\n\" +\n            \"script.projects(\\\"https://www.googleapis.com/auth/script.projects\\\", \\\"Create and update Google Apps Script projects\\\"),\\n\" +\n            \"script.projects.readonly(\\\"https://www.googleapis.com/auth/script.projects.readonly\\\", \\\"View Google Apps Script projects\\\"),\\n\" +\n            \"spreadsheets(\\\"https://www.googleapis.com/auth/spreadsheets\\\", \\\"See, edit, create, and delete your spreadsheets in Google Drive\\\"),\\n\" +\n            \"userinfo.email(\\\"https://www.googleapis.com/auth/userinfo.email\\\", \\\"View your email address\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform.read-only(\\\"https://www.googleapis.com/auth/cloud-platform.read-only\\\", \\\"View your data across Google Cloud Platform services\\\"),\\n\" +\n            \"bigquery(\\\"https://www.googleapis.com/auth/bigquery\\\", \\\"View and manage your data in Google BigQuery\\\"),\\n\" +\n            \"bigquery.insertdata(\\\"https://www.googleapis.com/auth/bigquery.insertdata\\\", \\\"Insert data into Google BigQuery\\\"),\\n\" +\n            \"bigquery.readonly(\\\"https://www.googleapis.com/auth/bigquery.readonly\\\", \\\"View your data in Google BigQuery\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform.read-only(\\\"https://www.googleapis.com/auth/cloud-platform.read-only\\\", \\\"View your data across Google Cloud Platform services\\\"),\\n\" +\n            \"devstorage.full_control(\\\"https://www.googleapis.com/auth/devstorage.full_control\\\", \\\"Manage your data and permissions in Google Cloud Storage\\\"),\\n\" +\n            \"devstorage.read_only(\\\"https://www.googleapis.com/auth/devstorage.read_only\\\", \\\"View your data in Google Cloud Storage\\\"),\\n\" +\n            \"devstorage.read_write(\\\"https://www.googleapis.com/auth/devstorage.read_write\\\", \\\"Manage your data in Google Cloud Storage\\\"),\\n\" +\n            \"bigquery(\\\"https://www.googleapis.com/auth/bigquery\\\", \\\"View and manage your data in Google BigQuery\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"bigquery(\\\"https://www.googleapis.com/auth/bigquery\\\", \\\"View and manage your data in Google BigQuery\\\"),\\n\" +\n            \"bigquery.readonly(\\\"https://www.googleapis.com/auth/bigquery.readonly\\\", \\\"View your data in Google BigQuery\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform.read-only(\\\"https://www.googleapis.com/auth/cloud-platform.read-only\\\", \\\"View your data across Google Cloud Platform services\\\"),\\n\" +\n            \"bigquery(\\\"https://www.googleapis.com/auth/bigquery\\\", \\\"View and manage your data in Google BigQuery\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"blogger(\\\"https://www.googleapis.com/auth/blogger\\\", \\\"Manage your Blogger account\\\"),\\n\" +\n            \"blogger.readonly(\\\"https://www.googleapis.com/auth/blogger.readonly\\\", \\\"View your Blogger account\\\"),\\n\" +\n            \"books(\\\"https://www.googleapis.com/auth/books\\\", \\\"Manage your books\\\"),\\n\" +\n            \"calendar(\\\"https://www.googleapis.com/auth/calendar\\\", \\\"See, edit, share, and permanently delete all the calendars you can access using Google Calendar\\\"),\\n\" +\n            \"calendar.events(\\\"https://www.googleapis.com/auth/calendar.events\\\", \\\"View and edit events on all your calendars\\\"),\\n\" +\n            \"calendar.events.readonly(\\\"https://www.googleapis.com/auth/calendar.events.readonly\\\", \\\"View events on all your calendars\\\"),\\n\" +\n            \"calendar.readonly(\\\"https://www.googleapis.com/auth/calendar.readonly\\\", \\\"View your calendars\\\"),\\n\" +\n            \"calendar.settings.readonly(\\\"https://www.googleapis.com/auth/calendar.settings.readonly\\\", \\\"View your Calendar settings\\\"),\\n\" +\n            \"verifiedaccess(\\\"https://www.googleapis.com/auth/verifiedaccess\\\", \\\"Verify your enterprise credentials\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"bigtable.admin(\\\"https://www.googleapis.com/auth/bigtable.admin\\\", \\\"Administer your Cloud Bigtable tables and clusters\\\"),\\n\" +\n            \"bigtable.admin.cluster(\\\"https://www.googleapis.com/auth/bigtable.admin.cluster\\\", \\\"Administer your Cloud Bigtable clusters\\\"),\\n\" +\n            \"bigtable.admin.instance(\\\"https://www.googleapis.com/auth/bigtable.admin.instance\\\", \\\"Administer your Cloud Bigtable clusters\\\"),\\n\" +\n            \"bigtable.admin.table(\\\"https://www.googleapis.com/auth/bigtable.admin.table\\\", \\\"Administer your Cloud Bigtable tables\\\"),\\n\" +\n            \"cloud-bigtable.admin(\\\"https://www.googleapis.com/auth/cloud-bigtable.admin\\\", \\\"Administer your Cloud Bigtable tables and clusters\\\"),\\n\" +\n            \"cloud-bigtable.admin.cluster(\\\"https://www.googleapis.com/auth/cloud-bigtable.admin.cluster\\\", \\\"Administer your Cloud Bigtable clusters\\\"),\\n\" +\n            \"cloud-bigtable.admin.table(\\\"https://www.googleapis.com/auth/cloud-bigtable.admin.table\\\", \\\"Administer your Cloud Bigtable tables\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform.read-only(\\\"https://www.googleapis.com/auth/cloud-platform.read-only\\\", \\\"View your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform.read-only(\\\"https://www.googleapis.com/auth/cloud-platform.read-only\\\", \\\"View your data across Google Cloud Platform services\\\"),\\n\" +\n            \"ndev.clouddns.readonly(\\\"https://www.googleapis.com/auth/ndev.clouddns.readonly\\\", \\\"View your DNS records hosted by Google Cloud DNS\\\"),\\n\" +\n            \"ndev.clouddns.readwrite(\\\"https://www.googleapis.com/auth/ndev.clouddns.readwrite\\\", \\\"View and manage your DNS records hosted by Google Cloud DNS\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"datastore(\\\"https://www.googleapis.com/auth/datastore\\\", \\\"View and manage your Google Cloud Datastore data\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud_debugger(\\\"https://www.googleapis.com/auth/cloud_debugger\\\", \\\"Use Stackdriver Debugger\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"datastore(\\\"https://www.googleapis.com/auth/datastore\\\", \\\"View and manage your Google Cloud Datastore data\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-identity.groups(\\\"https://www.googleapis.com/auth/cloud-identity.groups\\\", \\\"See, change, create, and delete any of the Cloud Identity Groups that you can access, including the members of each group\\\"),\\n\" +\n            \"cloud-identity.groups.readonly(\\\"https://www.googleapis.com/auth/cloud-identity.groups.readonly\\\", \\\"See any Cloud Identity Groups that you can access, including group members and their emails\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloudiot(\\\"https://www.googleapis.com/auth/cloudiot\\\", \\\"Register and manage devices in the Google Cloud IoT service\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloudkms(\\\"https://www.googleapis.com/auth/cloudkms\\\", \\\"View and manage your keys and secrets stored in Cloud Key Management Service\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform.read-only(\\\"https://www.googleapis.com/auth/cloud-platform.read-only\\\", \\\"View your data across Google Cloud Platform services\\\"),\\n\" +\n            \"logging.admin(\\\"https://www.googleapis.com/auth/logging.admin\\\", \\\"Administrate log data for your projects\\\"),\\n\" +\n            \"logging.read(\\\"https://www.googleapis.com/auth/logging.read\\\", \\\"View log data for your projects\\\"),\\n\" +\n            \"logging.write(\\\"https://www.googleapis.com/auth/logging.write\\\", \\\"Submit log data for your projects\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"monitoring(\\\"https://www.googleapis.com/auth/monitoring\\\", \\\"View and write monitoring data for all of your Google and third-party Cloud and API projects\\\"),\\n\" +\n            \"monitoring.read(\\\"https://www.googleapis.com/auth/monitoring.read\\\", \\\"View monitoring data for all of your Google Cloud and third-party projects\\\"),\\n\" +\n            \"monitoring.write(\\\"https://www.googleapis.com/auth/monitoring.write\\\", \\\"Publish metric data to your Google Cloud projects\\\"),\\n\" +\n            \"cloud-language(\\\"https://www.googleapis.com/auth/cloud-language\\\", \\\"Apply machine learning models to reveal the structure and meaning of text\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"compute(\\\"https://www.googleapis.com/auth/compute\\\", \\\"View and manage your Google Compute Engine resources\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"pubsub(\\\"https://www.googleapis.com/auth/pubsub\\\", \\\"View and manage Pub/Sub topics and subscriptions\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform.read-only(\\\"https://www.googleapis.com/auth/cloud-platform.read-only\\\", \\\"View your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloudruntimeconfig(\\\"https://www.googleapis.com/auth/cloudruntimeconfig\\\", \\\"Manage your Google Cloud Platform services' runtime configuration\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"sqlservice.admin(\\\"https://www.googleapis.com/auth/sqlservice.admin\\\", \\\"Manage your Google SQL Service instances\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud_search(\\\"https://www.googleapis.com/auth/cloud_search\\\", \\\"Index and serve your organization's data with Cloud Search\\\"),\\n\" +\n            \"cloud_search.debug(\\\"https://www.googleapis.com/auth/cloud_search.debug\\\", \\\"Index and serve your organization's data with Cloud Search\\\"),\\n\" +\n            \"cloud_search.indexing(\\\"https://www.googleapis.com/auth/cloud_search.indexing\\\", \\\"Index and serve your organization's data with Cloud Search\\\"),\\n\" +\n            \"cloud_search.query(\\\"https://www.googleapis.com/auth/cloud_search.query\\\", \\\"Search your organization's data in the Cloud Search index\\\"),\\n\" +\n            \"cloud_search.settings(\\\"https://www.googleapis.com/auth/cloud_search.settings\\\", \\\"Index and serve your organization's data with Cloud Search\\\"),\\n\" +\n            \"cloud_search.settings.indexing(\\\"https://www.googleapis.com/auth/cloud_search.settings.indexing\\\", \\\"Index and serve your organization's data with Cloud Search\\\"),\\n\" +\n            \"cloud_search.settings.query(\\\"https://www.googleapis.com/auth/cloud_search.settings.query\\\", \\\"Index and serve your organization's data with Cloud Search\\\"),\\n\" +\n            \"cloud_search.stats(\\\"https://www.googleapis.com/auth/cloud_search.stats\\\", \\\"Index and serve your organization's data with Cloud Search\\\"),\\n\" +\n            \"cloud_search.stats.indexing(\\\"https://www.googleapis.com/auth/cloud_search.stats.indexing\\\", \\\"Index and serve your organization's data with Cloud Search\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"source.full_control(\\\"https://www.googleapis.com/auth/source.full_control\\\", \\\"Manage your source code repositories\\\"),\\n\" +\n            \"source.read_only(\\\"https://www.googleapis.com/auth/source.read_only\\\", \\\"View the contents of your source code repositories\\\"),\\n\" +\n            \"source.read_write(\\\"https://www.googleapis.com/auth/source.read_write\\\", \\\"Manage the contents of your source code repositories\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"spanner.admin(\\\"https://www.googleapis.com/auth/spanner.admin\\\", \\\"Administer your Spanner databases\\\"),\\n\" +\n            \"spanner.data(\\\"https://www.googleapis.com/auth/spanner.data\\\", \\\"View and manage the contents of your Spanner databases\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform.read-only(\\\"https://www.googleapis.com/auth/cloud-platform.read-only\\\", \\\"View your data across Google Cloud Platform services\\\"),\\n\" +\n            \"devstorage.full_control(\\\"https://www.googleapis.com/auth/devstorage.full_control\\\", \\\"Manage your data and permissions in Google Cloud Storage\\\"),\\n\" +\n            \"devstorage.read_only(\\\"https://www.googleapis.com/auth/devstorage.read_only\\\", \\\"View your data in Google Cloud Storage\\\"),\\n\" +\n            \"devstorage.read_write(\\\"https://www.googleapis.com/auth/devstorage.read_write\\\", \\\"Manage your data in Google Cloud Storage\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"jobs(\\\"https://www.googleapis.com/auth/jobs\\\", \\\"Manage job postings\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform.read-only(\\\"https://www.googleapis.com/auth/cloud-platform.read-only\\\", \\\"View your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"trace.append(\\\"https://www.googleapis.com/auth/trace.append\\\", \\\"Write Trace data for a project or application\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-translation(\\\"https://www.googleapis.com/auth/cloud-translation\\\", \\\"Translate text from one language to another using Google Translate\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-vision(\\\"https://www.googleapis.com/auth/cloud-vision\\\", \\\"Apply machine learning models to understand and label images\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"compute(\\\"https://www.googleapis.com/auth/compute\\\", \\\"View and manage your Google Compute Engine resources\\\"),\\n\" +\n            \"compute.readonly(\\\"https://www.googleapis.com/auth/compute.readonly\\\", \\\"View your Google Compute Engine resources\\\"),\\n\" +\n            \"devstorage.full_control(\\\"https://www.googleapis.com/auth/devstorage.full_control\\\", \\\"Manage your data and permissions in Google Cloud Storage\\\"),\\n\" +\n            \"devstorage.read_only(\\\"https://www.googleapis.com/auth/devstorage.read_only\\\", \\\"View your data in Google Cloud Storage\\\"),\\n\" +\n            \"devstorage.read_write(\\\"https://www.googleapis.com/auth/devstorage.read_write\\\", \\\"Manage your data in Google Cloud Storage\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"content(\\\"https://www.googleapis.com/auth/content\\\", \\\"Manage your product listings and accounts for Google Shopping\\\"),\\n\" +\n            \"ddmconversions(\\\"https://www.googleapis.com/auth/ddmconversions\\\", \\\"Manage DoubleClick Digital Marketing conversions\\\"),\\n\" +\n            \"dfareporting(\\\"https://www.googleapis.com/auth/dfareporting\\\", \\\"View and manage DoubleClick for Advertisers reports\\\"),\\n\" +\n            \"dfatrafficking(\\\"https://www.googleapis.com/auth/dfatrafficking\\\", \\\"View and manage your DoubleClick Campaign Manager's (DCM) display ad campaigns\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"compute(\\\"https://www.googleapis.com/auth/compute\\\", \\\"View and manage your Google Compute Engine resources\\\"),\\n\" +\n            \"compute.readonly(\\\"https://www.googleapis.com/auth/compute.readonly\\\", \\\"View your Google Compute Engine resources\\\"),\\n\" +\n            \"userinfo.email(\\\"https://www.googleapis.com/auth/userinfo.email\\\", \\\"View your email address\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"dialogflow(\\\"https://www.googleapis.com/auth/dialogflow\\\", \\\"View, manage and query your Dialogflow agents\\\"),\\n\" +\n            \"display-video(\\\"https://www.googleapis.com/auth/display-video\\\", \\\"Create, see, edit, and permanently delete your Display & Video 360 entities and reports\\\"),\\n\" +\n            \"doubleclickbidmanager(\\\"https://www.googleapis.com/auth/doubleclickbidmanager\\\", \\\"View and manage your reports in DoubleClick Bid Manager\\\"),\\n\" +\n            \"doubleclickbidmanager(\\\"https://www.googleapis.com/auth/doubleclickbidmanager\\\", \\\"View and manage your reports in DoubleClick Bid Manager\\\"),\\n\" +\n            \"drive(\\\"https://www.googleapis.com/auth/drive\\\", \\\"See, edit, create, and delete all of your Google Drive files\\\"),\\n\" +\n            \"drive.appdata(\\\"https://www.googleapis.com/auth/drive.appdata\\\", \\\"View and manage its own configuration data in your Google Drive\\\"),\\n\" +\n            \"drive.file(\\\"https://www.googleapis.com/auth/drive.file\\\", \\\"View and manage Google Drive files and folders that you have opened or created with this app\\\"),\\n\" +\n            \"drive.metadata(\\\"https://www.googleapis.com/auth/drive.metadata\\\", \\\"View and manage metadata of files in your Google Drive\\\"),\\n\" +\n            \"drive.metadata.readonly(\\\"https://www.googleapis.com/auth/drive.metadata.readonly\\\", \\\"View metadata for files in your Google Drive\\\"),\\n\" +\n            \"drive.photos.readonly(\\\"https://www.googleapis.com/auth/drive.photos.readonly\\\", \\\"View the photos, videos and albums in your Google Photos\\\"),\\n\" +\n            \"drive.readonly(\\\"https://www.googleapis.com/auth/drive.readonly\\\", \\\"See and download all your Google Drive files\\\"),\\n\" +\n            \"drive.scripts(\\\"https://www.googleapis.com/auth/drive.scripts\\\", \\\"Modify your Google Apps Script scripts' behavior\\\"),\\n\" +\n            \"activity(\\\"https://www.googleapis.com/auth/activity\\\", \\\"View the activity history of your Google apps\\\"),\\n\" +\n            \"drive.activity(\\\"https://www.googleapis.com/auth/drive.activity\\\", \\\"View and add to the activity record of files in your Google Drive\\\"),\\n\" +\n            \"drive.activity.readonly(\\\"https://www.googleapis.com/auth/drive.activity.readonly\\\", \\\"View the activity record of files in your Google Drive\\\"),\\n\" +\n            \"apps.order(\\\"https://www.googleapis.com/auth/apps.order\\\", \\\"Manage users on your domain\\\"),\\n\" +\n            \"apps.order.readonly(\\\"https://www.googleapis.com/auth/apps.order.readonly\\\", \\\"Manage users on your domain\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"userinfo.email(\\\"https://www.googleapis.com/auth/userinfo.email\\\", \\\"View your email address\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"firebase(\\\"https://www.googleapis.com/auth/firebase\\\", \\\"View and administer all your Firebase data and settings\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform.read-only(\\\"https://www.googleapis.com/auth/cloud-platform.read-only\\\", \\\"View your data across Google Cloud Platform services\\\"),\\n\" +\n            \"firebase(\\\"https://www.googleapis.com/auth/firebase\\\", \\\"View and administer all your Firebase data and settings\\\"),\\n\" +\n            \"firebase.readonly(\\\"https://www.googleapis.com/auth/firebase.readonly\\\", \\\"View all your Firebase data and settings\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform.read-only(\\\"https://www.googleapis.com/auth/cloud-platform.read-only\\\", \\\"View your data across Google Cloud Platform services\\\"),\\n\" +\n            \"firebase(\\\"https://www.googleapis.com/auth/firebase\\\", \\\"View and administer all your Firebase data and settings\\\"),\\n\" +\n            \"firebase.readonly(\\\"https://www.googleapis.com/auth/firebase.readonly\\\", \\\"View all your Firebase data and settings\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"firebase(\\\"https://www.googleapis.com/auth/firebase\\\", \\\"View and administer all your Firebase data and settings\\\"),\\n\" +\n            \"firebase.readonly(\\\"https://www.googleapis.com/auth/firebase.readonly\\\", \\\"View all your Firebase data and settings\\\"),\\n\" +\n            \"fitness.activity.read(\\\"https://www.googleapis.com/auth/fitness.activity.read\\\", \\\"Use Google Fit to see and store your physical activity data\\\"),\\n\" +\n            \"fitness.activity.write(\\\"https://www.googleapis.com/auth/fitness.activity.write\\\", \\\"See and add to your Google Fit physical activity data\\\"),\\n\" +\n            \"fitness.blood_glucose.read(\\\"https://www.googleapis.com/auth/fitness.blood_glucose.read\\\", \\\"See info about your blood glucose in Google Fit. I consent to Google sharing my blood glucose information with this app.\\\"),\\n\" +\n            \"fitness.blood_glucose.write(\\\"https://www.googleapis.com/auth/fitness.blood_glucose.write\\\", \\\"See and add info about your blood glucose to Google Fit. I consent to Google sharing my blood glucose information with this app.\\\"),\\n\" +\n            \"fitness.blood_pressure.read(\\\"https://www.googleapis.com/auth/fitness.blood_pressure.read\\\", \\\"See info about your blood pressure in Google Fit. I consent to Google sharing my blood pressure information with this app.\\\"),\\n\" +\n            \"fitness.blood_pressure.write(\\\"https://www.googleapis.com/auth/fitness.blood_pressure.write\\\", \\\"See and add info about your blood pressure in Google Fit. I consent to Google sharing my blood pressure information with this app.\\\"),\\n\" +\n            \"fitness.body.read(\\\"https://www.googleapis.com/auth/fitness.body.read\\\", \\\"See info about your body measurements and heart rate in Google Fit\\\"),\\n\" +\n            \"fitness.body.write(\\\"https://www.googleapis.com/auth/fitness.body.write\\\", \\\"See and add info about your body measurements and heart rate to Google Fit\\\"),\\n\" +\n            \"fitness.body_temperature.read(\\\"https://www.googleapis.com/auth/fitness.body_temperature.read\\\", \\\"See info about your body temperature in Google Fit. I consent to Google sharing my body temperature information with this app.\\\"),\\n\" +\n            \"fitness.body_temperature.write(\\\"https://www.googleapis.com/auth/fitness.body_temperature.write\\\", \\\"See and add to info about your body temperature in Google Fit. I consent to Google sharing my body temperature information with this app.\\\"),\\n\" +\n            \"fitness.location.read(\\\"https://www.googleapis.com/auth/fitness.location.read\\\", \\\"See your Google Fit speed and distance data\\\"),\\n\" +\n            \"fitness.location.write(\\\"https://www.googleapis.com/auth/fitness.location.write\\\", \\\"See and add to your Google Fit location data\\\"),\\n\" +\n            \"fitness.nutrition.read(\\\"https://www.googleapis.com/auth/fitness.nutrition.read\\\", \\\"See info about your nutrition in Google Fit\\\"),\\n\" +\n            \"fitness.nutrition.write(\\\"https://www.googleapis.com/auth/fitness.nutrition.write\\\", \\\"See and add to info about your nutrition in Google Fit\\\"),\\n\" +\n            \"fitness.oxygen_saturation.read(\\\"https://www.googleapis.com/auth/fitness.oxygen_saturation.read\\\", \\\"See info about your oxygen saturation in Google Fit. I consent to Google sharing my oxygen saturation information with this app.\\\"),\\n\" +\n            \"fitness.oxygen_saturation.write(\\\"https://www.googleapis.com/auth/fitness.oxygen_saturation.write\\\", \\\"See and add info about your oxygen saturation in Google Fit. I consent to Google sharing my oxygen saturation information with this app.\\\"),\\n\" +\n            \"fitness.reproductive_health.read(\\\"https://www.googleapis.com/auth/fitness.reproductive_health.read\\\", \\\"See info about your reproductive health in Google Fit. I consent to Google sharing my reporductive health information with this app.\\\"),\\n\" +\n            \"fitness.reproductive_health.write(\\\"https://www.googleapis.com/auth/fitness.reproductive_health.write\\\", \\\"See and add info about your reproductive health in Google Fit. I consent to Google sharing my reporductive health information with this app.\\\"),\\n\" +\n            \"apps.alerts(\\\"https://www.googleapis.com/auth/apps.alerts\\\", \\\"See and delete your domain's G Suite alerts, and send alert feedback\\\"),\\n\" +\n            \"ediscovery(\\\"https://www.googleapis.com/auth/ediscovery\\\", \\\"Manage your eDiscovery data\\\"),\\n\" +\n            \"ediscovery.readonly(\\\"https://www.googleapis.com/auth/ediscovery.readonly\\\", \\\"View your eDiscovery data\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"genomics(\\\"https://www.googleapis.com/auth/genomics\\\", \\\"View and manage Genomics data\\\"),\\n\" +\n            \"(\\\"https://mail.google.com/\\\", \\\"Read, compose, send, and permanently delete all your email from Gmail\\\"),\\n\" +\n            \"gmail.addons.current.action.compose(\\\"https://www.googleapis.com/auth/gmail.addons.current.action.compose\\\", \\\"Manage drafts and send emails when you interact with the add-on\\\"),\\n\" +\n            \"gmail.addons.current.message.action(\\\"https://www.googleapis.com/auth/gmail.addons.current.message.action\\\", \\\"View your email messages when you interact with the add-on\\\"),\\n\" +\n            \"gmail.addons.current.message.metadata(\\\"https://www.googleapis.com/auth/gmail.addons.current.message.metadata\\\", \\\"View your email message metadata when the add-on is running\\\"),\\n\" +\n            \"gmail.addons.current.message.readonly(\\\"https://www.googleapis.com/auth/gmail.addons.current.message.readonly\\\", \\\"View your email messages when the add-on is running\\\"),\\n\" +\n            \"gmail.compose(\\\"https://www.googleapis.com/auth/gmail.compose\\\", \\\"Manage drafts and send emails\\\"),\\n\" +\n            \"gmail.insert(\\\"https://www.googleapis.com/auth/gmail.insert\\\", \\\"Insert mail into your mailbox\\\"),\\n\" +\n            \"gmail.labels(\\\"https://www.googleapis.com/auth/gmail.labels\\\", \\\"Manage mailbox labels\\\"),\\n\" +\n            \"gmail.metadata(\\\"https://www.googleapis.com/auth/gmail.metadata\\\", \\\"View your email message metadata such as labels and headers, but not the email body\\\"),\\n\" +\n            \"gmail.modify(\\\"https://www.googleapis.com/auth/gmail.modify\\\", \\\"View and modify but not delete your email\\\"),\\n\" +\n            \"gmail.readonly(\\\"https://www.googleapis.com/auth/gmail.readonly\\\", \\\"View your email messages and settings\\\"),\\n\" +\n            \"gmail.send(\\\"https://www.googleapis.com/auth/gmail.send\\\", \\\"Send email on your behalf\\\"),\\n\" +\n            \"gmail.settings.basic(\\\"https://www.googleapis.com/auth/gmail.settings.basic\\\", \\\"Manage your basic mail settings\\\"),\\n\" +\n            \"gmail.settings.sharing(\\\"https://www.googleapis.com/auth/gmail.settings.sharing\\\", \\\"Manage your sensitive mail settings, including who can manage your mail\\\"),\\n\" +\n            \"analytics(\\\"https://www.googleapis.com/auth/analytics\\\", \\\"View and manage your Google Analytics data\\\"),\\n\" +\n            \"analytics.edit(\\\"https://www.googleapis.com/auth/analytics.edit\\\", \\\"Edit Google Analytics management entities\\\"),\\n\" +\n            \"analytics.manage.users(\\\"https://www.googleapis.com/auth/analytics.manage.users\\\", \\\"Manage Google Analytics Account users by email address\\\"),\\n\" +\n            \"analytics.manage.users.readonly(\\\"https://www.googleapis.com/auth/analytics.manage.users.readonly\\\", \\\"View Google Analytics user permissions\\\"),\\n\" +\n            \"analytics.provision(\\\"https://www.googleapis.com/auth/analytics.provision\\\", \\\"Create a new Google Analytics account along with its default property and view\\\"),\\n\" +\n            \"analytics.readonly(\\\"https://www.googleapis.com/auth/analytics.readonly\\\", \\\"View your Google Analytics data\\\"),\\n\" +\n            \"analytics.user.deletion(\\\"https://www.googleapis.com/auth/analytics.user.deletion\\\", \\\"Manage Google Analytics user deletion requests\\\"),\\n\" +\n            \"classroom.announcements(\\\"https://www.googleapis.com/auth/classroom.announcements\\\", \\\"View and manage announcements in Google Classroom\\\"),\\n\" +\n            \"classroom.announcements.readonly(\\\"https://www.googleapis.com/auth/classroom.announcements.readonly\\\", \\\"View announcements in Google Classroom\\\"),\\n\" +\n            \"classroom.courses(\\\"https://www.googleapis.com/auth/classroom.courses\\\", \\\"Manage your Google Classroom classes\\\"),\\n\" +\n            \"classroom.courses.readonly(\\\"https://www.googleapis.com/auth/classroom.courses.readonly\\\", \\\"View your Google Classroom classes\\\"),\\n\" +\n            \"classroom.coursework.me(\\\"https://www.googleapis.com/auth/classroom.coursework.me\\\", \\\"Manage your course work and view your grades in Google Classroom\\\"),\\n\" +\n            \"classroom.coursework.me.readonly(\\\"https://www.googleapis.com/auth/classroom.coursework.me.readonly\\\", \\\"View your course work and grades in Google Classroom\\\"),\\n\" +\n            \"classroom.coursework.students(\\\"https://www.googleapis.com/auth/classroom.coursework.students\\\", \\\"Manage course work and grades for students in the Google Classroom classes you teach and view the course work and grades for classes you administer\\\"),\\n\" +\n            \"classroom.coursework.students.readonly(\\\"https://www.googleapis.com/auth/classroom.coursework.students.readonly\\\", \\\"View course work and grades for students in the Google Classroom classes you teach or administer\\\"),\\n\" +\n            \"classroom.guardianlinks.me.readonly(\\\"https://www.googleapis.com/auth/classroom.guardianlinks.me.readonly\\\", \\\"View your Google Classroom guardians\\\"),\\n\" +\n            \"classroom.guardianlinks.students(\\\"https://www.googleapis.com/auth/classroom.guardianlinks.students\\\", \\\"View and manage guardians for students in your Google Classroom classes\\\"),\\n\" +\n            \"classroom.guardianlinks.students.readonly(\\\"https://www.googleapis.com/auth/classroom.guardianlinks.students.readonly\\\", \\\"View guardians for students in your Google Classroom classes\\\"),\\n\" +\n            \"classroom.profile.emails(\\\"https://www.googleapis.com/auth/classroom.profile.emails\\\", \\\"View the email addresses of people in your classes\\\"),\\n\" +\n            \"classroom.profile.photos(\\\"https://www.googleapis.com/auth/classroom.profile.photos\\\", \\\"View the profile photos of people in your classes\\\"),\\n\" +\n            \"classroom.push-notifications(\\\"https://www.googleapis.com/auth/classroom.push-notifications\\\", \\\"Receive notifications about your Google Classroom data\\\"),\\n\" +\n            \"classroom.rosters(\\\"https://www.googleapis.com/auth/classroom.rosters\\\", \\\"Manage your Google Classroom class rosters\\\"),\\n\" +\n            \"classroom.rosters.readonly(\\\"https://www.googleapis.com/auth/classroom.rosters.readonly\\\", \\\"View your Google Classroom class rosters\\\"),\\n\" +\n            \"classroom.student-submissions.me.readonly(\\\"https://www.googleapis.com/auth/classroom.student-submissions.me.readonly\\\", \\\"View your course work and grades in Google Classroom\\\"),\\n\" +\n            \"classroom.student-submissions.students.readonly(\\\"https://www.googleapis.com/auth/classroom.student-submissions.students.readonly\\\", \\\"View course work and grades for students in the Google Classroom classes you teach or administer\\\"),\\n\" +\n            \"classroom.topics(\\\"https://www.googleapis.com/auth/classroom.topics\\\", \\\"See, create, and edit topics in Google Classroom\\\"),\\n\" +\n            \"classroom.topics.readonly(\\\"https://www.googleapis.com/auth/classroom.topics.readonly\\\", \\\"View topics in Google Classroom\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform.read-only(\\\"https://www.googleapis.com/auth/cloud-platform.read-only\\\", \\\"View your data across Google Cloud Platform services\\\"),\\n\" +\n            \"ndev.cloudman(\\\"https://www.googleapis.com/auth/ndev.cloudman\\\", \\\"View and manage your Google Cloud Platform management resources and deployment status information\\\"),\\n\" +\n            \"ndev.cloudman.readonly(\\\"https://www.googleapis.com/auth/ndev.cloudman.readonly\\\", \\\"View your Google Cloud Platform management resources and deployment status information\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"documents(\\\"https://www.googleapis.com/auth/documents\\\", \\\"View and manage your Google Docs documents\\\"),\\n\" +\n            \"documents.readonly(\\\"https://www.googleapis.com/auth/documents.readonly\\\", \\\"View your Google Docs documents\\\"),\\n\" +\n            \"drive(\\\"https://www.googleapis.com/auth/drive\\\", \\\"See, edit, create, and delete all of your Google Drive files\\\"),\\n\" +\n            \"drive.file(\\\"https://www.googleapis.com/auth/drive.file\\\", \\\"View and manage Google Drive files and folders that you have opened or created with this app\\\"),\\n\" +\n            \"drive.readonly(\\\"https://www.googleapis.com/auth/drive.readonly\\\", \\\"See and download all your Google Drive files\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"firebase(\\\"https://www.googleapis.com/auth/firebase\\\", \\\"View and administer all your Firebase data and settings\\\"),\\n\" +\n            \"userinfo.email(\\\"https://www.googleapis.com/auth/userinfo.email\\\", \\\"View your email address\\\"),\\n\" +\n            \"userinfo.profile(\\\"https://www.googleapis.com/auth/userinfo.profile\\\", \\\"See your personal info, including any personal info you've made publicly available\\\"),\\n\" +\n            \"openid(\\\"openid\\\", \\\"Associate you with your personal info on Google\\\"),\\n\" +\n            \"androidpublisher(\\\"https://www.googleapis.com/auth/androidpublisher\\\", \\\"View and manage your Google Play Developer account\\\"),\\n\" +\n            \"androidpublisher(\\\"https://www.googleapis.com/auth/androidpublisher\\\", \\\"View and manage your Google Play Developer account\\\"),\\n\" +\n            \"androidenterprise(\\\"https://www.googleapis.com/auth/androidenterprise\\\", \\\"Manage corporate Android devices\\\"),\\n\" +\n            \"games(\\\"https://www.googleapis.com/auth/games\\\", \\\"Create, edit, and delete your Google Play Games activity\\\"),\\n\" +\n            \"drive.appdata(\\\"https://www.googleapis.com/auth/drive.appdata\\\", \\\"View and manage its own configuration data in your Google Drive\\\"),\\n\" +\n            \"games(\\\"https://www.googleapis.com/auth/games\\\", \\\"Create, edit, and delete your Google Play Games activity\\\"),\\n\" +\n            \"androidpublisher(\\\"https://www.googleapis.com/auth/androidpublisher\\\", \\\"View and manage your Google Play Developer account\\\"),\\n\" +\n            \"drive(\\\"https://www.googleapis.com/auth/drive\\\", \\\"See, edit, create, and delete all of your Google Drive files\\\"),\\n\" +\n            \"drive.file(\\\"https://www.googleapis.com/auth/drive.file\\\", \\\"View and manage Google Drive files and folders that you have opened or created with this app\\\"),\\n\" +\n            \"drive.readonly(\\\"https://www.googleapis.com/auth/drive.readonly\\\", \\\"See and download all your Google Drive files\\\"),\\n\" +\n            \"spreadsheets(\\\"https://www.googleapis.com/auth/spreadsheets\\\", \\\"See, edit, create, and delete your spreadsheets in Google Drive\\\"),\\n\" +\n            \"spreadsheets.readonly(\\\"https://www.googleapis.com/auth/spreadsheets.readonly\\\", \\\"View your Google Spreadsheets\\\"),\\n\" +\n            \"profile(\\\"profile\\\", \\\"View your basic profile info\\\"),\\n\" +\n            \"email(\\\"email\\\", \\\"View your email address\\\"),\\n\" +\n            \"openid(\\\"openid\\\", \\\"Authenticate using OpenID Connect\\\"),\\n\" +\n            \"siteverification(\\\"https://www.googleapis.com/auth/siteverification\\\", \\\"Manage the list of sites and domains you control\\\"),\\n\" +\n            \"siteverification.verify_only(\\\"https://www.googleapis.com/auth/siteverification.verify_only\\\", \\\"Manage your new site verifications with Google\\\"),\\n\" +\n            \"drive(\\\"https://www.googleapis.com/auth/drive\\\", \\\"See, edit, create, and delete all of your Google Drive files\\\"),\\n\" +\n            \"drive.file(\\\"https://www.googleapis.com/auth/drive.file\\\", \\\"View and manage Google Drive files and folders that you have opened or created with this app\\\"),\\n\" +\n            \"drive.readonly(\\\"https://www.googleapis.com/auth/drive.readonly\\\", \\\"See and download all your Google Drive files\\\"),\\n\" +\n            \"presentations(\\\"https://www.googleapis.com/auth/presentations\\\", \\\"View and manage your Google Slides presentations\\\"),\\n\" +\n            \"presentations.readonly(\\\"https://www.googleapis.com/auth/presentations.readonly\\\", \\\"View your Google Slides presentations\\\"),\\n\" +\n            \"spreadsheets(\\\"https://www.googleapis.com/auth/spreadsheets\\\", \\\"See, edit, create, and delete your spreadsheets in Google Drive\\\"),\\n\" +\n            \"spreadsheets.readonly(\\\"https://www.googleapis.com/auth/spreadsheets.readonly\\\", \\\"View your Google Spreadsheets\\\"),\\n\" +\n            \"apps.groups.migration(\\\"https://www.googleapis.com/auth/apps.groups.migration\\\", \\\"Manage messages in groups on your domain\\\"),\\n\" +\n            \"apps.groups.settings(\\\"https://www.googleapis.com/auth/apps.groups.settings\\\", \\\"View and manage the settings of a G Suite group\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"indexing(\\\"https://www.googleapis.com/auth/indexing\\\", \\\"Submit data to Google for indexing\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"apps.licensing(\\\"https://www.googleapis.com/auth/apps.licensing\\\", \\\"View and manage G Suite licenses for your domain\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"manufacturercenter(\\\"https://www.googleapis.com/auth/manufacturercenter\\\", \\\"Manage your product listings for Google Manufacturer Center\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"openid(\\\"openid\\\", \\\"Authenticate using OpenID Connect\\\"),\\n\" +\n            \"profile(\\\"profile\\\", \\\"View your basic profile info\\\"),\\n\" +\n            \"email(\\\"email\\\", \\\"View your email address\\\"),\\n\" +\n            \"openid(\\\"openid\\\", \\\"Associate you with your personal info on Google\\\"),\\n\" +\n            \"contacts(\\\"https://www.googleapis.com/auth/contacts\\\", \\\"See, edit, download, and permanently delete your contacts\\\"),\\n\" +\n            \"contacts.other.readonly(\\\"https://www.googleapis.com/auth/contacts.other.readonly\\\", \\\"See and download contact info automatically saved in your \\\"Other contacts\\\"\\\"),\\n\" +\n            \"contacts.readonly(\\\"https://www.googleapis.com/auth/contacts.readonly\\\", \\\"See and download your contacts\\\"),\\n\" +\n            \"directory.readonly(\\\"https://www.googleapis.com/auth/directory.readonly\\\", \\\"See and download your organization's GSuite directory\\\"),\\n\" +\n            \"user.addresses.read(\\\"https://www.googleapis.com/auth/user.addresses.read\\\", \\\"View your street addresses\\\"),\\n\" +\n            \"user.birthday.read(\\\"https://www.googleapis.com/auth/user.birthday.read\\\", \\\"View your complete date of birth\\\"),\\n\" +\n            \"user.emails.read(\\\"https://www.googleapis.com/auth/user.emails.read\\\", \\\"View your email addresses\\\"),\\n\" +\n            \"user.gender.read(\\\"https://www.googleapis.com/auth/user.gender.read\\\", \\\"See your gender\\\"),\\n\" +\n            \"user.organization.read(\\\"https://www.googleapis.com/auth/user.organization.read\\\", \\\"See your education, work history and org info\\\"),\\n\" +\n            \"user.phonenumbers.read(\\\"https://www.googleapis.com/auth/user.phonenumbers.read\\\", \\\"View your phone numbers\\\"),\\n\" +\n            \"userinfo.email(\\\"https://www.googleapis.com/auth/userinfo.email\\\", \\\"View your email address\\\"),\\n\" +\n            \"userinfo.profile(\\\"https://www.googleapis.com/auth/userinfo.profile\\\", \\\"See your personal info, including any personal info you've made publicly available\\\"),\\n\" +\n            \"photoslibrary(\\\"https://www.googleapis.com/auth/photoslibrary\\\", \\\"View and manage your Google Photos library\\\"),\\n\" +\n            \"photoslibrary.appendonly(\\\"https://www.googleapis.com/auth/photoslibrary.appendonly\\\", \\\"Add to your Google Photos library\\\"),\\n\" +\n            \"photoslibrary.readonly(\\\"https://www.googleapis.com/auth/photoslibrary.readonly\\\", \\\"View your Google Photos library\\\"),\\n\" +\n            \"photoslibrary.readonly.appcreateddata(\\\"https://www.googleapis.com/auth/photoslibrary.readonly.appcreateddata\\\", \\\"Manage photos added by this app\\\"),\\n\" +\n            \"photoslibrary.sharing(\\\"https://www.googleapis.com/auth/photoslibrary.sharing\\\", \\\"Manage and add to shared albums on your behalf\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"userinfo.email(\\\"https://www.googleapis.com/auth/userinfo.email\\\", \\\"View your email address\\\"),\\n\" +\n            \"userinfo.email(\\\"https://www.googleapis.com/auth/userinfo.email\\\", \\\"View your email address\\\"),\\n\" +\n            \"doubleclicksearch(\\\"https://www.googleapis.com/auth/doubleclicksearch\\\", \\\"View and manage your advertising data in DoubleClick Search\\\"),\\n\" +\n            \"webmasters(\\\"https://www.googleapis.com/auth/webmasters\\\", \\\"View and manage Search Console data for your verified sites\\\"),\\n\" +\n            \"webmasters.readonly(\\\"https://www.googleapis.com/auth/webmasters.readonly\\\", \\\"View Search Console data for your verified sites\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"servicecontrol(\\\"https://www.googleapis.com/auth/servicecontrol\\\", \\\"Manage your Google Service Control data\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform.read-only(\\\"https://www.googleapis.com/auth/cloud-platform.read-only\\\", \\\"View your data across Google Cloud Platform services\\\"),\\n\" +\n            \"service.management(\\\"https://www.googleapis.com/auth/service.management\\\", \\\"Manage your Google API service configuration\\\"),\\n\" +\n            \"service.management.readonly(\\\"https://www.googleapis.com/auth/service.management.readonly\\\", \\\"View your Google API service configuration\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"service.management(\\\"https://www.googleapis.com/auth/service.management\\\", \\\"Manage your Google API service configuration\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"cloud-platform.read-only(\\\"https://www.googleapis.com/auth/cloud-platform.read-only\\\", \\\"View your data across Google Cloud Platform services\\\"),\\n\" +\n            \"service.management(\\\"https://www.googleapis.com/auth/service.management\\\", \\\"Manage your Google API service configuration\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"monitoring(\\\"https://www.googleapis.com/auth/monitoring\\\", \\\"View and write monitoring data for all of your Google and third-party Cloud and API projects\\\"),\\n\" +\n            \"monitoring.write(\\\"https://www.googleapis.com/auth/monitoring.write\\\", \\\"Publish metric data to your Google Cloud projects\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"streetviewpublish(\\\"https://www.googleapis.com/auth/streetviewpublish\\\", \\\"Publish and manage your 360 photos on Google Street View\\\"),\\n\" +\n            \"tagmanager.delete.containers(\\\"https://www.googleapis.com/auth/tagmanager.delete.containers\\\", \\\"Delete your Google Tag Manager containers\\\"),\\n\" +\n            \"tagmanager.edit.containers(\\\"https://www.googleapis.com/auth/tagmanager.edit.containers\\\", \\\"Manage your Google Tag Manager container and its subcomponents, excluding versioning and publishing\\\"),\\n\" +\n            \"tagmanager.edit.containerversions(\\\"https://www.googleapis.com/auth/tagmanager.edit.containerversions\\\", \\\"Manage your Google Tag Manager container versions\\\"),\\n\" +\n            \"tagmanager.manage.accounts(\\\"https://www.googleapis.com/auth/tagmanager.manage.accounts\\\", \\\"View and manage your Google Tag Manager accounts\\\"),\\n\" +\n            \"tagmanager.manage.users(\\\"https://www.googleapis.com/auth/tagmanager.manage.users\\\", \\\"Manage user permissions of your Google Tag Manager account and container\\\"),\\n\" +\n            \"tagmanager.publish(\\\"https://www.googleapis.com/auth/tagmanager.publish\\\", \\\"Publish your Google Tag Manager container versions\\\"),\\n\" +\n            \"tagmanager.readonly(\\\"https://www.googleapis.com/auth/tagmanager.readonly\\\", \\\"View your Google Tag Manager container and its subcomponents\\\"),\\n\" +\n            \"tasks(\\\"https://www.googleapis.com/auth/tasks\\\", \\\"Create, edit, organize, and delete all your tasks\\\"),\\n\" +\n            \"tasks.readonly(\\\"https://www.googleapis.com/auth/tasks.readonly\\\", \\\"View your tasks\\\"),\\n\" +\n            \"cloud-platform(\\\"https://www.googleapis.com/auth/cloud-platform\\\", \\\"View and manage your data across Google Cloud Platform services\\\"),\\n\" +\n            \"youtube(\\\"https://www.googleapis.com/auth/youtube\\\", \\\"Manage your YouTube account\\\"),\\n\" +\n            \"youtube.readonly(\\\"https://www.googleapis.com/auth/youtube.readonly\\\", \\\"View your YouTube account\\\"),\\n\" +\n            \"youtubepartner(\\\"https://www.googleapis.com/auth/youtubepartner\\\", \\\"View and manage your assets and associated content on YouTube\\\"),\\n\" +\n            \"yt-analytics-monetary.readonly(\\\"https://www.googleapis.com/auth/yt-analytics-monetary.readonly\\\", \\\"View monetary and non-monetary YouTube Analytics reports for your YouTube content\\\"),\\n\" +\n            \"yt-analytics.readonly(\\\"https://www.googleapis.com/auth/yt-analytics.readonly\\\", \\\"View YouTube Analytics reports for your YouTube content\\\"),\\n\" +\n            \"youtube(\\\"https://www.googleapis.com/auth/youtube\\\", \\\"Manage your YouTube account\\\"),\\n\" +\n            \"youtube.channel-memberships.creator(\\\"https://www.googleapis.com/auth/youtube.channel-memberships.creator\\\", \\\"See a list of your current active channel members, their current level, and when they became a member\\\"),\\n\" +\n            \"youtube.force-ssl(\\\"https://www.googleapis.com/auth/youtube.force-ssl\\\", \\\"See, edit, and permanently delete your YouTube videos, ratings, comments and captions\\\"),\\n\" +\n            \"youtube.readonly(\\\"https://www.googleapis.com/auth/youtube.readonly\\\", \\\"View your YouTube account\\\"),\\n\" +\n            \"youtube.upload(\\\"https://www.googleapis.com/auth/youtube.upload\\\", \\\"Manage your YouTube videos\\\"),\\n\" +\n            \"youtubepartner(\\\"https://www.googleapis.com/auth/youtubepartner\\\", \\\"View and manage your assets and associated content on YouTube\\\"),\\n\" +\n            \"youtubepartner-channel-audit(\\\"https://www.googleapis.com/auth/youtubepartner-channel-audit\\\", \\\"View private information of your YouTube channel relevant during the audit process with a YouTube partner\\\"),\\n\" +\n            \"yt-analytics-monetary.readonly(\\\"https://www.googleapis.com/auth/yt-analytics-monetary.readonly\\\", \\\"View monetary and non-monetary YouTube Analytics reports for your YouTube content\\\"),\\n\" +\n            \"yt-analytics.readonly(\\\"https://www.googleapis.com/auth/yt-analytics.readonly\\\", \\\"View YouTube Analytics reports for your YouTube content\\\"),\";\n        List<String> scopes = Arrays.stream(scopeStr.split(\"\\n\")).distinct().sorted(Comparator.reverseOrder()).collect(Collectors.toList());\n        System.out.println(scopes.size());\n        for (String s : scopes) {\n            String name = s.substring(0, s.indexOf(\"(\"));\n            String scope = s.substring(s.indexOf(\"(\"));\n            name = name.replaceAll(\"\\\\.\", \"-\")\n                .replaceAll(\"-\", \"_\")\n                .toUpperCase();\n            System.out.println(name + scope);\n        }\n    }\n}\n"
  },
  {
    "path": "src/test/java/me/zhyd/oauth/utils/StringUtilsTest.java",
    "content": "package me.zhyd.oauth.utils;\n\nimport org.junit.Assert;\nimport org.junit.Rule;\nimport org.junit.Test;\nimport org.junit.rules.ExpectedException;\n\npublic class StringUtilsTest {\n    @Rule\n    public final ExpectedException thrown =\n        ExpectedException.none();\n\n    @Test\n    public void isEmptyNonEmptyInput() {\n        Assert.assertFalse(StringUtils.isEmpty(\"non-empty string\"));\n    }\n\n    @Test\n    public void isEmptyEmptyInput() {\n        Assert.assertTrue(StringUtils.isEmpty(\"\"));\n    }\n\n    @Test\n    public void isEmptyInputNull() {\n        Assert.assertTrue(StringUtils.isEmpty(null));\n    }\n\n    @Test\n    public void isNotEmptyNonEmptyInput() {\n        Assert.assertTrue(StringUtils.isNotEmpty(\"non-empty string\"));\n    }\n\n    @Test\n    public void isNotEmptyEmptyInput() {\n        Assert.assertFalse(StringUtils.isNotEmpty(\"\"));\n    }\n\n    @Test\n    public void isNotEmptyInputNull() {\n        Assert.assertFalse(StringUtils.isNotEmpty(null));\n    }\n\n    @Test\n    public void appendIfNotContainAppendedStringNotPresent() {\n        // (Check the case where appendStr doesn't occur in str)\n        final String str = \"Prefix \";\n        final String appendStr = \"suffix\";\n        final String otherwise = \"should be discarded\";\n\n        final String result =\n            StringUtils.appendIfNotContain(str, appendStr, otherwise);\n\n        Assert.assertEquals(\"Prefix suffix\", result);\n    }\n\n    @Test\n    public void appendIfNotContainAppendedStringPresent() {\n        // (Check the case where appendStr occurs in str)\n        final String str = \"Prefix \";\n        final String appendStr = \"Prefix\";\n        final String otherwise = \"should be appended\";\n\n        final String result =\n            StringUtils.appendIfNotContain(str, appendStr, otherwise);\n\n        Assert.assertEquals(\"Prefix should be appended\", result);\n    }\n\n    @Test\n    public void appendIfNotContainEmptyString() {\n        // (Check the special-case for str being empty)\n        final String str = \"\";\n        final String appendStr = \"should not be appended\";\n        final String otherwise = \"should also not be appended\";\n\n        final String result =\n            StringUtils.appendIfNotContain(str, appendStr, otherwise);\n\n        Assert.assertEquals(\"\", result);\n    }\n\n    @Test\n    public void appendIfNotContainAppendingEmptyString() {\n        // (Check the special-case for appendStr being empty)\n        final String str = \"should be kept\";\n        final String appendStr = \"\";\n        final String otherwise = \"should also not be appended\";\n\n        final String result =\n            StringUtils.appendIfNotContain(str, appendStr, otherwise);\n\n        Assert.assertEquals(\"should be kept\", result);\n    }\n}\n"
  },
  {
    "path": "src/test/java/me/zhyd/oauth/utils/UrlBuilderTest.java",
    "content": "package me.zhyd.oauth.utils;\n\nimport me.zhyd.oauth.config.AuthConfig;\nimport me.zhyd.oauth.config.AuthDefaultSource;\nimport me.zhyd.oauth.request.AuthWeChatOpenRequest;\nimport org.junit.Assert;\nimport org.junit.Test;\n\n/**\n * <p>\n * UrlBuilder测试类\n * </p>\n *\n * @author yangkai.shen (https://xkcoding.com)\n * @date Created in 2019-07-18 16:36\n */\npublic class UrlBuilderTest {\n    @Test\n    public void testUrlBuilder() {\n        AuthConfig config = AuthConfig.builder()\n            .clientId(\"appid-110110110\")\n            .clientSecret(\"secret-110110110\")\n            .redirectUri(\"https://xkcoding.com\")\n            .build();\n        String build = UrlBuilder.fromBaseUrl(AuthDefaultSource.WECHAT_OPEN.authorize())\n            .queryParam(\"appid\", config.getClientId())\n            .queryParam(\"redirect_uri\", config.getRedirectUri())\n            .queryParam(\"response_type\", \"code\")\n            .queryParam(\"scope\", \"snsapi_login\")\n            .queryParam(\"state\", \"\")\n            .build(false);\n        System.out.println(build);\n        AuthWeChatOpenRequest request = new AuthWeChatOpenRequest(config);\n        String authorize = request.authorize(\"state\");\n        System.out.println(authorize);\n    }\n\n    @Test\n    public void build() {\n        String url = UrlBuilder.fromBaseUrl(\"https://www.zhyd.me\")\n            .queryParam(\"name\", \"yadong.zhang\")\n            .build();\n        Assert.assertEquals(url, \"https://www.zhyd.me?name=yadong.zhang\");\n\n        url = UrlBuilder.fromBaseUrl(url)\n            .queryParam(\"github\", \"https://github.com/zhangyd-c\")\n            .build();\n        Assert.assertEquals(url, \"https://www.zhyd.me?name=yadong.zhang&github=https://github.com/zhangyd-c\");\n    }\n\n    @Test\n    public void build1() {\n        String url = UrlBuilder.fromBaseUrl(\"https://www.zhyd.me\")\n            .queryParam(\"name\", \"yadong.zhang\")\n            .build(true);\n        Assert.assertEquals(url, \"https://www.zhyd.me?name=yadong.zhang\");\n\n        url = UrlBuilder.fromBaseUrl(url)\n            .queryParam(\"github\", \"https://github.com/zhangyd-c\")\n            .build(true);\n        Assert.assertEquals(url, \"https://www.zhyd.me?name=yadong.zhang&github=https%3A%2F%2Fgithub.com%2Fzhangyd-c\");\n    }\n}\n"
  },
  {
    "path": "src/test/java/me/zhyd/oauth/utils/UuidUtilsTest.java",
    "content": "package me.zhyd.oauth.utils;\n\nimport org.junit.Test;\n\npublic class UuidUtilsTest {\n\n    @Test\n    public void getUUID() {\n\n        String uuid = UuidUtils.getUUID();\n        System.out.println(uuid);\n    }\n}\n"
  }
]