We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hello~we can use cookieJar to get super administrator privileges.
public static void main(String[] args) { String url = "http://localhost:8070/signin"; FormBody loginBody = new FormBody.Builder() .add("username", "apollo") .add("password", "admin") .build(); OkHttpClient client = new OkHttpClient.Builder().cookieJar(new CookieJar() { private final HashMap<String, List<okhttp3.Cookie>> cookieStore = new HashMap<>(); @Override public void saveFromResponse(HttpUrl url, List<okhttp3.Cookie> cookies) { cookieStore.put(url.host(), cookies); } @Override public List<okhttp3.Cookie> loadForRequest(HttpUrl url) { List<okhttp3.Cookie> cookies = cookieStore.get(url.host()); return cookies != null ? cookies : new ArrayList<>(); } }).build(); //调用登录接口,刷新cookie到CookieJar Request request = new Request.Builder().url(url).post(loginBody).build(); Response response = client.newCall(request).execute(); try { //调用业务接口,通过loadForRequest请求授权等管理器接口 String url2 = "http://localhost:8070/consumers/509c8cc78e667529eaaf332c44a845b9c58857b5/assign-role?type=AppRole"; String json = "{\"appId\":\"sentinel-dashboard\"}"; RequestBody body2 = RequestBody.create(JSON, json); Response response2 = client.newCall(request2).execute(); System.out.println(response2.body().string()); } catch (IOException e) { e.printStackTrace(); } }
The text was updated successfully, but these errors were encountered:
+1
Sorry, something went wrong.
No branches or pull requests
hello~we can use cookieJar to get super administrator privileges.
The text was updated successfully, but these errors were encountered: