I. 클라이언트 ID 설정
승인된 리다이렉션 URI
http://localhost:8080/login/oauth2/code/google
스프링부트에서는 반드시 이 주소로 적어야 한다.
- 종종 http://localhost:8080/authorize/oauth2/code/google로 리다이렉션 되는 경우가 있어서 이 주소도 추가했다.
II. scope 설정
- 구글 oauth2 용 설정파일 생성
resources/application-oauth.properties
spring.security.oauth2.client.registration.google.client-id=829901496470-54rufes6a8ur76os805ptftkgh2fb816.apps.googleusercontent.com
spring.security.oauth2.client.registration.google.client-secret=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
spring.security.oauth2.client.registration.google.scope=profile,email
- 설정 파일 적용
resources/application.properties
spring.profiles.include=oauth
여기까지만 나와있는 예제들이 많다.
구글 드라이브나 구글 시트 권한 추가하는 법
scope=profile,email, https://www.googleapis.com/auth/drive, https://www.googleapis.com/auth/spreadsheets
그냥 여기에서 원하는 스콥 찾아서 주소 전부 다 적으면 된다.
https://www.googleapis.com/auth/userinfo.email은email만 적으니까
https://www.googleapis.com/auth/drive는 drive만 적으면 되는 줄 알았는데 아니었다.
III. 로그인 할 때마다 매번 리프레시토큰 받아오기
resources/application.properties
spring.security.oauth2.client.provider.google.authorization-uri=https://accounts.google.com/'Java > Spring Boot' 카테고리의 다른 글
| [SpringBoot] 이클립스에서 메인 클레스를 찾을 수 없음 (1) | 2024.05.11 |
|---|---|
| [SpringBoot] Could not find acceptable representation (1) | 2024.05.11 |
| [SpringBoot] 엔드포인트 권한 에러 (1) | 2024.05.11 |
| [SpringBoot] Spring Seurity 적용 후 회원가입 안됨 (1) | 2024.05.11 |
| [SpringBoot] 서버 시작 시 에러 (1) | 2024.05.11 |