项目集成钉钉登录

项目集成钉钉登录获取三个重要参数 钉钉登录 https open dev dingtalk com v1 fe old loginMan 记录以下三个信息 appId appSecret 和回调域名 后面我们会用到 2 代码 import javax servlet http HttpServletR

大家好,我是讯享网,很高兴认识大家。

获取三个重要参数

钉钉登录:https://open-dev.dingtalk.com/v1/fe/old#/loginMan

在这里插入图片描述
讯享网

记录以下三个信息:appId、appSecret和回调域名,后面我们会用到。
在这里插入图片描述

2. 代码

import javax.servlet.http.HttpServletResponse; import java.io.IOException; / * @author wql * @date 2021/11/19 17:24 */ @RestController @RequestMapping("/oauth") public class DingDingLoginController { 
    @RequestMapping("/render") public void renderAuth(HttpServletResponse response) throws IOException { 
    AuthRequest authRequest = getAuthRequest(); response.sendRedirect(authRequest.authorize(AuthStateUtils.createState())); } @RequestMapping("/callback") public Object login(AuthCallback callback) { 
    AuthRequest authRequest = getAuthRequest(); return authRequest.login(callback); } private AuthRequest getAuthRequest() { 
    return new AuthDingTalkRequest(AuthConfig.builder() .clientId("dingoarg8xwz0o2iurhmsz") .clientSecret("hSlZNiq3jIEnwsMuWwsTdymUruPgc_cjXjMB4lERAAHTnz1Lh257kdu38yIJmmyE") .redirectUri("http://localhost:20021/oauth/callback") .build()); } } 

讯享网

3. 启动项目

浏览器调 render 接口即可

4. 返回数据

讯享网{ 
    "code": 2000, "msg": null, "data": { 
    "uuid": "ebxJIZiPqeiPoeINHnTH2bRwiEiE", "username": "王xx", "nickname": "王xx", "avatar": null, "blog": null, "company": null, "location": null, "email": null, "remark": null, "gender": "UNKNOWN", "source": "DINGTALK", "token": { 
    "accessToken": null, "expireIn": 0, "refreshToken": null, "refreshTokenExpireIn": 0, "uid": null, "openId": "WS6t4WUY1b79TFUVKlUc5QiEiE", "accessCode": null, "unionId": "ebxJIZiPqeiPoeINHnTH2bRwiEiE", "scope": null, "tokenType": null, "idToken": null, "macAlgorithm": null, "macKey": null, "code": null, "oauthToken": null, "oauthTokenSecret": null, "userId": null, "screenName": null, "oauthCallbackConfirmed": null }, "rawUserInfo": { 
    "nick": "王xx", "unionid": "ebxJIZiPqeiPoeINHnTH2bRwiEiE", "dingId": "$:LWCP_v1:$6h5ewoOME66PPLzmNpXts3/PN/1BM5nG", "openid": "WS6t4WUY1b79TFUVKlUc5QiEiE", "main_org_auth_high_level": true } } } 
小讯
上一篇 2025-01-16 08:20
下一篇 2025-03-14 14:48

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/109878.html