1
0
mirror of synced 2026-05-22 21:53:18 +00:00

refactor: extract common method

This commit is contained in:
Hongwei Peng
2019-07-18 18:23:45 +08:00
parent d0375ce31a
commit 66ee684e1f
4 changed files with 14 additions and 17 deletions
@@ -14,6 +14,8 @@ import me.zhyd.oauth.url.entity.AuthUserInfoEntity;
import java.util.HashMap;
import java.util.Map;
import static me.zhyd.oauth.utils.GlobalAuthUtil.parseQueryToMap;
/**
* 微软登录
*
@@ -40,12 +42,10 @@ public class AuthMicrosoftRequest extends AuthDefaultRequest {
* @return token对象
*/
private AuthToken getToken(String accessTokenUrl) {
Map<String, Object> paramMap = new HashMap<>(6);
HttpUtil.decodeParamMap(accessTokenUrl, "UTF-8").forEach(paramMap::put);
HttpResponse response = HttpRequest.post(accessTokenUrl)
.header("Host", "https://login.microsoftonline.com")
.header("Content-Type", "application/x-www-form-urlencoded")
.form(paramMap)
.contentType("application/x-www-form-urlencoded")
.form(parseQueryToMap(accessTokenUrl))
.execute();
String accessTokenStr = response.body();
JSONObject accessTokenObject = JSONObject.parseObject(accessTokenStr);