Skip to content
This repository has been archived by the owner on Nov 7, 2022. It is now read-only.

Commit

Permalink
✨ Support android
Browse files Browse the repository at this point in the history
  • Loading branch information
omg-xtao committed May 14, 2022
1 parent 645436a commit 309b9ce
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/main/java/com/xtaolabs/gcauth_oauth/GCAuth_OAuth.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import emu.grasscutter.Grasscutter;
import emu.grasscutter.plugin.Plugin;
import emu.grasscutter.server.dispatch.DispatchHttpJsonHandler;
import static emu.grasscutter.Configuration.*;

import com.xtaolabs.gcauth_oauth.handler.JsonHandler;
import com.xtaolabs.gcauth_oauth.handler.VerifyHandler;
import com.xtaolabs.gcauth_oauth.handler.RequestHandler;

Expand Down Expand Up @@ -39,12 +39,7 @@ public void loadTwitterLogin() {
String folder_name = PLUGINS_FOLDER + "/GCAuth/OAuth/";
Express app = Grasscutter.getDispatchServer().getServer();

app.get("/Api/twitter_login", new DispatchHttpJsonHandler(
String.format("{\"code\":200,\"data\":{\"auth_url\":\"%s\",\"info\":\"\",\"msg\":\"Success\",\"status\":1}}",
"http" + (DISPATCH_ENCRYPTION.useEncryption ? "s" : "") + "://"
+ lr(DISPATCH_INFO.accessAddress, DISPATCH_INFO.bindAddress) + ":"
+ lr(DISPATCH_INFO.accessPort, DISPATCH_INFO.bindPort) + "/gcauth_oauth/login.html")
));
app.get("/Api/twitter_login", new JsonHandler());

app.post("/gcauth_oauth/login", new RequestHandler());

Expand Down
21 changes: 21 additions & 0 deletions src/main/java/com/xtaolabs/gcauth_oauth/handler/JsonHandler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.xtaolabs.gcauth_oauth.handler;

import java.io.IOException;

import express.http.HttpContextHandler;
import express.http.Request;
import express.http.Response;


public final class JsonHandler implements HttpContextHandler {
@Override
public void handle(Request req, Response res) throws IOException {
String Login_Html_Url = "https://account.mihoyo.com/gcauth_oauth/login.html";
res.set("server", "tsa_m");
res.set("Content-Type", "application/json; charset=utf-8");
res.set("access-control-allow-credentials", "true");
res.set("access-control-allow-origin", "https://account.hoyoverse.com");
res.send(String.format("{\"code\":200,\"data\":{\"auth_url\":\"%s\",\"info\":\"\",\"msg\":\"Success\",\"status\":1}}",
Login_Html_Url));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
public final class VerifyJson {
public String thirdparty;
public String access_token;
public String game_key;
public String cb_url;
public Boolean no_regist;
}

0 comments on commit 309b9ce

Please sign in to comment.