0

add google oauth2

This commit is contained in:
lcarlyl
2022-04-21 18:34:10 +03:00
parent 3fa106491a
commit ae394f5ae0
15 changed files with 155 additions and 0 deletions

33
google/README.MD Normal file
View File

@@ -0,0 +1,33 @@
# Spring Boot + OAuth2 Google
<img alt="Spring Boot" width="auto" height="100" src="../docs/spring-boot.svg">
<img alt="Discord" 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
![](docs/1.png)
3. Заполняем обязательно следующие поля
- **Application type**: `Web application`
- **Homepage URL**: `http://127.0.0.1:8080`
- **Authorization callback URL**: `http://127.0.0.1:8080/login/oauth2/code/google`
![](docs/2.png)
5. Получаем **Client secret/Client ID**
![](docs/3.png)
### Настройка 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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
```