0
Files
spring-oauth2-examples/gitlab/README.MD
2022-04-21 19:44:20 +03:00

35 lines
1.2 KiB
Markdown

# Spring Boot + OAuth2 GitHub
<img alt="Spring Boot" width="auto" height="100" src="../docs/spring-boot.svg">
<img alt="GitLab" width="auto" height="100" src="docs/gitlab.svg">
## Перед запуском
### Создание OAuth Application
Для запуска понадобиться обзавестить своим **GitLab**.
1. Переходим в [Applications](https://gitlab.com/-/profile/applications)
![](docs/1.png)
2. Заполняем обязательно следующие поля
- **Name**: `MY_OAUTH2-APP`
- **Redirect URI**: `http://127.0.0.1:8080/login/oauth2/code/gitlab`
- **Scopes**: `read_user`
![](docs/2.png)
3. Получаем **Client secret/Client ID**
![](docs/3.png)
### Настройка Spring
Открываем файл `src/main/resources/application.yml` и указываем там **Client ID** и **Client secrets**:
```yaml
spring:
security:
oauth2:
client:
registration:
gitlab:
client-id: 0781ee8ca191018d2b60eb68b1a0b2af5c4765fbbf51cd297c95fa59b9ff99ae
client-secret: ef19ea39b87f3be6532108d455ae7f962c1e77132b82fa1a7a4f6f93470534de
```