내 Spring 애플리케이션에서 다음과 같은 Google Authorization 구현을 사용하고 있습니다.
public Credential authenticate(final NetHttpTransport httpTransport) throws IOException {
Optional<InputStream> credentialsInputStream = Optional.ofNullable(AuthenticationService.class.getResourceAsStream(credentialsFilePath));
GoogleClientSecrets clientSecrets =
GoogleClientSecrets.load(
jsonFactory,
new InputStreamReader(credentialsInputStream
.orElseThrow(() -> new FileNotFoundException("Resource not found: " + credentialsFilePath))));
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
httpTransport, jsonFactory, clientSecrets, authenticationScopes)
.setDataStoreFactory(new FileDataStoreFactory(new File(tokensDirectoryPath)))
.setAccessType(ACCESS_TYPE)
.build();
LocalServerReceiver receiver = new LocalServerReceiver.Builder().setPort(AUTHENTICATION_RECEIVER_PORT).build();
return new AuthorizationCodeInstalledApp(flow, receiver).authorize(TECHNICAL_USER_ID);
}
이 솔루션은 콘솔에 Google 인증 URL이 표시됩니다.
Please open the following address in your browser:
https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=1234567890.apps.googleusercontent.com&redirect_uri=http://localhost:8888/Callback&response_type=code&scope=https://www.googleapis.com/auth/drive%20https://www.googleapis.com/auth/spreadsheets%20https://www.googleapis.com/auth/calendar
Attempting to open that address in the default browser now...
문제는 앱에서 URL 방문을 요청할 때이 단계를 생략 할 수있는 방법이 있습니까? 이상적인 상황은 사용자 / 개발자 / 운영자의 조치없이 전체 프로세스가 완전히 자동으로 진행될 수있는 경우입니다.