1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Spring Security 5 で OAuth2をつかう。

Posted at

前回、Spring Securityをやってみましたが、今回は、OAuth2をやってみたいと思います。
GoogleやFacebookで認証することになりますが、今回はGoogleでやってみます。

環境

Eclipse Version: 2019-03 (4.11.0)
Java 11
Spring Boot 2.1.5
Spring Security 5.1.5

前準備

Google Cloud Platformのコンソールで必要な情報を設定します。

下の画面が表示されたら、「作成」のリンクをクリックしてください。
image

下の入力画面が表示されるのでプロジェクト名を適当につけて「作成」を押下
image

作成が終わったら、メニューの「APIとサービス」 -> 「認証情報」を選択
image

下の画面が表示されたら、OAuth同意画面の設定を選択

必要な情報を下の画面に入力し「保存」を押下する
image

  • アプリケーションの種類 … 「内部」を選択
  • アプリケーション名 …「Sample」を入力

下の画面が表示されたら、「認証情報の作成」 -> 「OAuthクライアントID」を選択
image

下の画面が表示されるので、必要な情報を入力し、「作成」を押下する
image

作成が終わると、以下の画面が表示されるので、クライアントIDと、クライアントシークレットを控えておく。
image

新規プロジェクトを作成する

  • Eclipseを起動する
  • ファイル > 新規 > プロジェクトを選択
  • ウィザードで、「Spring スターター・プロジェクト」を選択
    -「次へ」を押下
  • 名前は適当設定、Javaバージョン「11」、「Gradle」を選択し「次へ」を押下
  • 「DevTools」「セキュリティー」「Web」「Thymleaf」「OAuth2クライアント」を選択し、「完了」を押下
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?