diff --git a/src/main/java/me/zhyd/oauth/enums/scope/AuthWeiboScope.java b/src/main/java/me/zhyd/oauth/enums/scope/AuthWeiboScope.java
new file mode 100644
index 0000000000000000000000000000000000000000..73451d6bed2e4f98c2898ff0fd8720b6436dd044
--- /dev/null
+++ b/src/main/java/me/zhyd/oauth/enums/scope/AuthWeiboScope.java
@@ -0,0 +1,53 @@
+package me.zhyd.oauth.enums.scope;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * 微博平台 OAuth 授权范围
+ *
+ * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
+ * @version 1.0.0
+ * @since 1.0.0
+ */
+@Getter
+@AllArgsConstructor
+public enum AuthWeiboScope implements AuthScope {
+
+ /**
+ * {@code scope} 含义,以{@code description} 为准
+ */
+ ALL("all", "获取所有权限", true),
+ EMAIL("email", "用户的联系邮箱,接口文档", false),
+ DIRECT_MESSAGES_WRITE("direct_messages_write", "私信发送接口,接口文档", false),
+ DIRECT_MESSAGES_READ("direct_messages_read", "私信读取接口,接口文档", false),
+ INVITATION_WRITE("invitation_write", "邀请发送接口,接口文档", false),
+ FRIENDSHIPS_GROUPS_READ("friendships_groups_read", "好友分组读取接口组,接口文档", false),
+ FRIENDSHIPS_GROUPS_WRITE("friendships_groups_write", "好友分组写入接口组,接口文档", false),
+ STATUSES_TO_ME_READ("statuses_to_me_read", "定向微博读取接口组,接口文档", false),
+ FOLLOW_APP_OFFICIAL_MICROBLOG("follow_app_official_microblog", "关注应用官方微博,该参数不对应具体接口,只需在应用控制台填写官方帐号即可。填写的路径:我的应用-选择自己的应用-应用信息-基本信息-官方运营账号(默认值是应用开发者帐号)", false);
+
+ private String scope;
+ private String description;
+ private boolean isDefault;
+
+ public static List getDefaultScopes() {
+ AuthWeiboScope[] scopes = AuthWeiboScope.values();
+ List defaultScopes = new ArrayList<>();
+ for (AuthWeiboScope scope : scopes) {
+ if (scope.isDefault()) {
+ defaultScopes.add(scope);
+ }
+ }
+ return defaultScopes;
+ }
+
+ public static List listScope() {
+ return Arrays.stream(AuthWeiboScope.values()).map(AuthWeiboScope::getScope).collect(Collectors.toList());
+ }
+}
diff --git a/src/main/java/me/zhyd/oauth/request/AuthWeiboRequest.java b/src/main/java/me/zhyd/oauth/request/AuthWeiboRequest.java
index 1f18c83ab7912368206ffa1ecd5f4ef8dd214ee5..fd6917abd5b598e8057bdcc4a181d0a5037df212 100644
--- a/src/main/java/me/zhyd/oauth/request/AuthWeiboRequest.java
+++ b/src/main/java/me/zhyd/oauth/request/AuthWeiboRequest.java
@@ -1,18 +1,19 @@
package me.zhyd.oauth.request;
import com.alibaba.fastjson.JSONObject;
-import me.zhyd.oauth.utils.HttpUtils;
import com.xkcoding.http.support.HttpHeader;
import me.zhyd.oauth.cache.AuthStateCache;
import me.zhyd.oauth.config.AuthConfig;
import me.zhyd.oauth.config.AuthDefaultSource;
import me.zhyd.oauth.enums.AuthResponseStatus;
import me.zhyd.oauth.enums.AuthUserGender;
+import me.zhyd.oauth.enums.scope.AuthWeiboScope;
import me.zhyd.oauth.exception.AuthException;
import me.zhyd.oauth.model.AuthCallback;
import me.zhyd.oauth.model.AuthResponse;
import me.zhyd.oauth.model.AuthToken;
import me.zhyd.oauth.model.AuthUser;
+import me.zhyd.oauth.utils.HttpUtils;
import me.zhyd.oauth.utils.IpUtils;
import me.zhyd.oauth.utils.StringUtils;
import me.zhyd.oauth.utils.UrlBuilder;
@@ -93,6 +94,13 @@ public class AuthWeiboRequest extends AuthDefaultRequest {
.build();
}
+ @Override
+ public String authorize(String state) {
+ return UrlBuilder.fromBaseUrl(super.authorize(state))
+ .queryParam("scope", this.getScopes(",", false, AuthWeiboScope.getDefaultScopes()))
+ .build();
+ }
+
@Override
public AuthResponse revoke(AuthToken authToken) {
String response = doGetRevoke(authToken);