|
|
@@ -88,7 +88,7 @@ public class ChatGptAuthServiceImpl implements ChatGptAuthService {
|
|
|
String codeVerifier = "vNniyozytMkk-MuJrIyfYcf3oUlviwEqO0MqwhDIu1U";
|
|
|
String codeChallenge = "bAj3s8u55ymQ_OI7_JY7dPxvREDKAl_MMr_jBC74zRQ";
|
|
|
|
|
|
- String url = "https://auth0.openai.com/authorize?client_id=pdlLIX2Y72MIl2rhLhTE9VV9bN905kBh&audience=https%3A%2F%2Fapi.openai.com%2Fv1&redirect_uri=com.openai.chat%3A%2F%2Fauth0.openai.com%2Fios%2Fcom.openai.chat%2Fcallback&scope=openid%20email%20profile%20offline_access%20model.request%20model.read%20organization.read%20offline&response_type=code&code_challenge=" + codeChallenge + "&code_challenge_method=S256&prompt=login";
|
|
|
+ String url = "https://auth0.openai.com/authorize?client_id=pdlLIX2Y72MIl2rhLhTE9VV9bN905kBh&audience=https%3A%2F%2Fapi.openai.com%2Fv1&redirect_uri=com.openai.chat%3A%2F%2Fauth0.openai.com%2Fios%2Fcom.openai.chat%2Fcallback&scope=openid%20email%20profile%20offline_access%20model.request%20model.read%20organization.read%20offline&response_type=code&code_challenge=" + codeChallenge + "&code_challenge_method=S256&prompt=login&preauth_cookie=" + getPreauthCookie();
|
|
|
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
|
|
|
|
@@ -106,6 +106,17 @@ public class ChatGptAuthServiceImpl implements ChatGptAuthService {
|
|
|
return refresh_token;
|
|
|
}
|
|
|
|
|
|
+ private String getPreauthCookie() {
|
|
|
+ String body = HttpUtil.get("https://ai.fakeopen.com/auth/preauth");
|
|
|
+ JSONObject res = new JSONObject(body);
|
|
|
+ String preauthCookie = res.getStr("preauth_cookie");
|
|
|
+ if (StringUtils.isBlank(preauthCookie)) {
|
|
|
+ throw BusinessRuntimeException.getInstance("Get preauth cookie failed.");
|
|
|
+ }else {
|
|
|
+ return preauthCookie;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public String getAccessToken(String username) throws Exception {
|
|
|
Account account = accountMapper.selectOne(Wrappers.lambdaQuery(Account.class).eq(Account::getAccount, username));
|