🔖 merge #101
This commit is contained in:
@@ -119,9 +119,16 @@ public class AuthConfig {
|
||||
private String deviceId;
|
||||
|
||||
/**
|
||||
* 喜马拉雅:客户端包名,如果client_os_type为1或2时必填。对Android客户端是包名,对IOS客户端是Bundle ID
|
||||
* 喜马拉雅:客户端操作系统类型,1-iOS系统,2-Android系统,3-Web
|
||||
*
|
||||
* @since 1.15.8
|
||||
* @since 1.15.9
|
||||
*/
|
||||
private Integer clientOsType;
|
||||
|
||||
/**
|
||||
* 喜马拉雅:客户端包名,如果 {@link AuthConfig#clientOsType} 为1或2时必填。对Android客户端是包名,对IOS客户端是Bundle ID
|
||||
*
|
||||
* @since 1.15.9
|
||||
*/
|
||||
private String packId;
|
||||
}
|
||||
|
||||
@@ -12,14 +12,17 @@ import me.zhyd.oauth.model.AuthToken;
|
||||
import me.zhyd.oauth.model.AuthUser;
|
||||
import me.zhyd.oauth.utils.GlobalAuthUtils;
|
||||
import me.zhyd.oauth.utils.UrlBuilder;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.TreeMap;
|
||||
|
||||
/**
|
||||
* 喜马拉雅登录
|
||||
*
|
||||
* @author zwzch (zwzch4j@gmail.com)
|
||||
* @since 1.15.8
|
||||
* @since 1.15.9
|
||||
*/
|
||||
public class AuthXmlyRequest extends AuthDefaultRequest {
|
||||
|
||||
@@ -89,7 +92,7 @@ public class AuthXmlyRequest extends AuthDefaultRequest {
|
||||
public AuthUser getUserInfo(AuthToken authToken) {
|
||||
Map<String, String> map = new TreeMap<>();
|
||||
map.put("app_key", config.getClientId());
|
||||
map.put("client_os_type", "2");
|
||||
map.put("client_os_type", Optional.ofNullable(config.getClientOsType()).orElse(3).toString());
|
||||
map.put("device_id", config.getDeviceId());
|
||||
map.put("pack_id", config.getPackId());
|
||||
map.put("access_token", authToken.getAccessToken());
|
||||
@@ -113,7 +116,7 @@ public class AuthXmlyRequest extends AuthDefaultRequest {
|
||||
*
|
||||
* @param object 接口返回的结果
|
||||
*/
|
||||
private void checkResponse(JSONObject object){
|
||||
private void checkResponse(JSONObject object) {
|
||||
if (object.containsKey("errcode")) {
|
||||
throw new AuthException(object.getIntValue("error_no"), object.getString("error_desc"));
|
||||
}
|
||||
|
||||
@@ -38,6 +38,12 @@ public class AuthChecker {
|
||||
if (isSupported && AuthDefaultSource.CODING == source) {
|
||||
isSupported = StringUtils.isNotEmpty(config.getCodingGroupName());
|
||||
}
|
||||
if (isSupported && AuthDefaultSource.XMLY == source) {
|
||||
isSupported = StringUtils.isNotEmpty(config.getDeviceId()) && null != config.getClientOsType();
|
||||
if (isSupported) {
|
||||
isSupported = config.getClientOsType() == 3 || StringUtils.isNotEmpty(config.getPackId());
|
||||
}
|
||||
}
|
||||
return isSupported;
|
||||
}
|
||||
|
||||
|
||||
@@ -227,6 +227,7 @@ public class GlobalAuthUtils {
|
||||
* @param params 加密参数
|
||||
* @param clientSecret 平台应用的授权key
|
||||
* @return Signature
|
||||
* @since 1.15.9
|
||||
*/
|
||||
public static String generateXmlySignature(Map<String, String> params, String clientSecret) {
|
||||
TreeMap<String, String> map = new TreeMap<>(params);
|
||||
|
||||
Reference in New Issue
Block a user