use of com.publiccms.view.pojo.oauth.OauthConfig in project PublicCMS-preview by sanluan.
the class QQOauthComponent method getUserInfo.
/*
* http://wiki.connect.qq.com/get_user_info
*/
@Override
public OauthUser getUserInfo(short siteId, OauthAccess oauthAccess) throws ClientProtocolException, IOException {
OauthConfig config = getConfig(siteId);
if (null != oauthAccess && null != config) {
StringBuilder sb = new StringBuilder("https://graph.qq.com/user/get_user_info?access_token=");
sb.append(oauthAccess.getAccessToken()).append("&oauth_consumer_key=").append(config.getAppKey()).append("&openid=").append(oauthAccess.getOpenId()).append("&format=format");
String html = get(sb.toString());
if (CommonUtils.notEmpty(html)) {
Map<String, Object> map = objectMapper.readValue(html, new TypeReference<Map<String, Object>>() {
});
if (0 == (Integer) map.get("ret")) {
return new OauthUser(oauthAccess.getOpenId(), (String) map.get("nickname"), (String) map.get("figureurl_qq_2"), "男".equals(map.get("gender")) ? "m" : "f");
}
}
}
return null;
}
use of com.publiccms.view.pojo.oauth.OauthConfig in project PublicCMS-preview by sanluan.
the class WechatOauthComponent method getAccessToken.
/*
*
*/
@Override
public OauthAccess getAccessToken(short siteId, String code) throws ClientProtocolException, IOException {
OauthConfig config = getConfig(siteId);
if (null != config) {
StringBuilder sb = new StringBuilder("https://api.weixin.qq.com/sns/oauth2/access_token?appid=");
sb.append(config.getAppKey()).append("&secret=").append(config.getAppSecret()).append("&code=").append(code).append("&grant_type=authorization_code");
String html = get(sb.toString());
Map<String, Object> map = objectMapper.readValue(html, new TypeReference<Map<String, Object>>() {
});
if (null != map.get("access_token")) {
return new OauthAccess(code, (String) map.get("access_token"), (String) map.get("openid"));
}
}
return null;
}
use of com.publiccms.view.pojo.oauth.OauthConfig in project PublicCMS-preview by sanluan.
the class WeiboOauthComponent method getAuthorizeUrl.
/*
* http://open.weibo.com/wiki/Oauth2/authorize
*/
public String getAuthorizeUrl(short siteId, String state, boolean mobile) {
OauthConfig config = getConfig(siteId);
if (null != config) {
StringBuilder sb = new StringBuilder("https://api.weibo.com/oauth2/authorize?client_id=");
sb.append(config.getAppKey()).append("&redirect_uri=").append(config.getReturnUrl()).append("&scope=email&state=").append(state);
if (mobile) {
sb.append("&display=mobile");
}
return sb.toString();
}
return null;
}
Aggregations