0
Files
spring-oauth2-examples/google
2022-04-21 18:34:10 +03:00
..
2022-04-21 18:34:10 +03:00
2022-04-21 18:34:10 +03:00
2022-04-21 18:34:10 +03:00
2022-04-21 18:34:10 +03:00

Spring Boot + OAuth2 Google

Spring Boot Discord

Перед запуском

Создание OAuth

Для запуска понадобиться обзавестить своим Google OAuth.

  1. Переходим в Google APIs console credentials
  2. Создаём новый OAuth Client ID
  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
  4. Получаем Client secret/Client ID

Настройка Spring

Открываем файл src/main/resources/application.yml и указываем там Client ID и Client secrets:

spring:
  security:
    oauth2:
      client:
        registration:
          google:
            client-id: 704750524716-tnqc2islqao8tobjbrgvtte0fq8o39uv.apps.googleusercontent.com
            client-secret: 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