RestTemplate 请求
2024-09-08 18:44:02
@Autowired
private RestTemplate httpRestTemplate; String code= request.getParameter("code");
URI url = new URI("http://10.20.60.107:8088/ssoserver/moc2/token");
// 参数拼装
LinkedMultiValueMap<String, String> postParam = new LinkedMultiValueMap<String, String>() ;
postParam.add("grant_type", "authorization_code");
postParam.add("client_id", "222");
postParam.add("client_secret", "45B6E9F1D9A4F10873EB7B2B9BC2CB9AEC11E6AF4ED50980734E62ABFDE91210");
postParam.add("redirect_uri", "http://10.20.60.107:8088/ssoserver/third/oauth/login/callback");
postParam.add("code", code);
ResponseEntity<JSONObject> forEntity = httpRestTemplate.postForEntity(url, postParam, JSONObject.class);
JSONObject object = forEntity.getBody();
String accessToken = object.getString("access_token");
最新文章
- Struts2入门(四)——数据输入验证
- 外网访问内网工具ngrok tunnel 使用总结
- 关于html转pdf
- Windows_RTM_RC
- c#自制视屏监控
- MVC3异常处理的方法
- springmvc学习第二天
- apache2.4 以上设定gzip压缩
- xml 解析 java 基础复习
- Web交互设计优化的简易check list
- 蓝牙4.0LED灯控方案
- 启动Activity时显示空白界面的问题
- android File文件的读写操作
- html中的div span和frameset框架标签
- 使用github管理你的代码
- AngularJS进阶(三十七)IE浏览器兼容性后续
- js常用的400个特效
- Keil的断点调试问题解决
- 奇偶数判断2(if else+switch语句)
- Linux的crontab应注意事项
热门文章
- Python如何像awk一样分割字符串
- Safari浏览器对SVG中的<;foreignObject>;标签支持不友好,渲染容易错位
- 8. 字符串转整数 (atoi)
- 用Java写一个分布式缓存——缓存淘汰算法
- Linux C 用GPS时间更新系统时间的方法。
- WeetCode4 —— 二叉树遍历与树型DP
- Unity_UIWidgets新手入门
- petite-vue和Vue的比较
- 图书管理员(NOIP 2017 PJT2)
- 插入排序(CSP-J 2021 T2)我有新思路了,链接:https://www.cnblogs.com/wjk53233/p/16533752.html