Я пытаюсь реализовать вход в Google на стороне сервера, и API, который я вызываю, - https://accounts.google.com/o/oauth2/auth?.Если я вызываю это напрямую из браузера, он перенаправляет меня на мой redirect_uri с кодом в качестве параметра запроса, но если я запускаю его как бэкэнд для остальных веб-сервисов, он ничего не делает, хотя ответ составляет 200
код бэкенда:
public void oauth2Service(){
OkHttpClient client = new OkHttpClient();
StringBuilder oauth2GetCodeUrl = new StringBuilder();
oauth2GetCodeUrl.append(env.getProperty("oauth2_url"));
oauth2GetCodeUrl.append("scope=").append(getGoogleSignInProperties.getScope());
oauth2GetCodeUrl.append("&redirect_uri=").append(getGoogleSignInProperties.getRedirect_uri());
oauth2GetCodeUrl.append("&response_type=").append(getGoogleSignInProperties.getResponse_id());
oauth2GetCodeUrl.append("&client_id=").append(getGoogleSignInProperties.getClient_id());
oauth2GetCodeUrl.append("&approval_prompt=").append(getGoogleSignInProperties.getApproval_prompt());
Request request = new Request.Builder()
.url(oauth2GetCodeUrl.toString()).get()
.addHeader("content-type", "application/x-www-form-urlencoded")
.addHeader("cache-control", "no-cache")
.build();
try {
Response response = client.newCall(request).execute();
System.out.println(response.toString());
} catch (IOException e) {
e.printStackTrace();
}
}
API должен перенаправить меня на URI перенаправления, уже упомянутый в запросе
Строка ответа: Response {protocol = http / 1.1, code = 200, message = OK, url = https://accounts.google.com/ServiceLogin?passive=1209600&continue=https://accounts.google.com/o/oauth2/auth?scope%3Demail%26redirect_uri%3Dhttp://localhost:8080/MovieSearch/webapi/googleOAuthCallback%26response_type%3Dcode%26client_id%3D52424919169-remgpb2h4nhdua57plc1cem4p0qo4if8.apps.googleusercontent.com%26approval_prompt%3Dforce%26from_login%3D1%26as%3DhYtl9Ra4jWxbygJmS2uAiw&followup=https://accounts.google.com/o/oauth2/auth?scope%3Demail%26redirect_uri%3Dhttp://localhost:8080/MovieSearch/webapi/googleOAuthCallback%26response_type%3Dcode%26client_id%3D52424919169-remgpb2h4nhdua57plc1cem4p0qo4if8.apps.googleusercontent.com%26approval_prompt%3Dforce%26from_login%3D1%26as%3DhYtl9Ra4jWxbygJmS2uAiw&oauth=1&sarp=1&scc=1}