34 lines
1.2 KiB
Markdown
34 lines
1.2 KiB
Markdown
# Spring Boot + OAuth2 GitHub
|
|
|
|
<img alt="Spring Boot" width="auto" height="100" src="../docs/spring-boot.svg">
|
|
<img alt="Discord" width="auto" height="100" src="docs/github-white.svg">
|
|
|
|
## Перед запуском
|
|
### Создание OAuth App
|
|
Для запуска понадобиться обзавестить своим **GitHub OAuth App**.
|
|
|
|
1. Переходим в [Developer settings](https://github.com/settings/developers)
|
|
2. Создаём новое OAuth приложение
|
|

|
|
3. Заполняем обязательно следующие поля
|
|
- **Homepage URL**: `http://127.0.0.1:8080`
|
|
- **Authorization callback URL**: `http://127.0.0.1:8080/login/oauth2/code/github`
|
|

|
|
4. Сгенерировать новый **Client secrets**
|
|

|
|

|
|
|
|
### Настройка Spring
|
|
Открываем файл `src/main/resources/application.yml` и указываем там **Client ID** и **Client secrets**:
|
|
|
|
```yaml
|
|
spring:
|
|
security:
|
|
oauth2:
|
|
client:
|
|
registration:
|
|
github:
|
|
client-id: f9bbf16cc3a93663282f
|
|
client-secret: 16f203668e25bfe44513d2a7b4925d62bb100783
|
|
```
|