34 lines
1.3 KiB
Markdown
34 lines
1.3 KiB
Markdown
# Spring Boot + OAuth2 Google
|
|
|
|
<img alt="Spring Boot" width="auto" height="100" src="../docs/spring-boot.svg">
|
|
<img alt="Google" width="auto" height="100" src="docs/google.svg">
|
|
|
|
## Перед запуском
|
|
### Создание OAuth
|
|
Для запуска понадобиться обзавестить своим **Google OAuth**.
|
|
|
|
1. Переходим в [Google APIs console credentials](https://console.cloud.google.com/apis/credentials?project=silent-fuze-322306)
|
|
2. Создаём новый OAuth Client ID
|
|

|
|
3. Заполняем обязательно следующие поля
|
|
- **Application type**: `Web application`
|
|
- **Name**: `MY-GOOGLE-APP`
|
|
- **Authorization callback URL**: `http://127.0.0.1:8080/login/oauth2/code/google`
|
|

|
|
5. Получаем **Client secret/Client ID**
|
|

|
|
|
|
### Настройка Spring
|
|
Открываем файл `src/main/resources/application.yml` и указываем там **Client ID** и **Client secrets**:
|
|
|
|
```yaml
|
|
spring:
|
|
security:
|
|
oauth2:
|
|
client:
|
|
registration:
|
|
google:
|
|
client-id: 704750524716-tnqc2islqao8tobjbrgvtte0fq8o39uv.apps.googleusercontent.com
|
|
client-secret: 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
|
|
```
|