1.获取code码,调用getCode,会打开网址
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.util.JSONPObject;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import top.yokey.svapi.utils.Config;
import java.util.HashMap;
import java.util.Map;
public class DyGrant {
static String host = "https://open.douyin.com";
public static void getCode(){
String url = host +"/platform/oauth/connect?client_key="+ Config.getValue("dy_client_ID") +"&response_type=code&scope="+Config.getValue("dy_auth_scope") +"&redirect_uri="+Config.getValue("dy_auth_redirect_url");
BaseHttp.openUrl(url);
}
public static String getAccessToken(){
String url = host +"/oauth/access_token?client_key="+ Config.getValue("dy_client_ID") +"&client_secret="+Config.getValue("dy_client_SERCRET")+"&code="+Config.getValue("dy_auth_code")+"&grant_type=authorization_code";
String code = BaseHttp.get(url);
System.out.println(code);
Map returnMap = (Map) JSONObject.parse(code);
Map data = (Map) returnMap.get("data");
String access_token = (String) data.get("access_token");
String open_id = (String)data.get("open_id");
String refresh_token = (String)data.get("refresh_token");
String refresh_expires_in = data.get("refresh_expires_in") + "";
String scope = data.get("scope") + "";
if(access_token != null){
Con