-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
feat: Kakao, Naver social login
- Loading branch information
Showing
5 changed files
with
123 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
InjeRecipe/src/main/java/com/example/injerecipe/oauth2/userinfo/KakaoOAuth2UserInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.example.injerecipe.oauth2.userinfo; | ||
|
||
import java.util.Map; | ||
|
||
public class KakaoOAuth2UserInfo extends OAuth2UserInfo { | ||
|
||
public KakaoOAuth2UserInfo(Map<String, Object> attributes) { | ||
super(attributes); | ||
} | ||
|
||
@Override | ||
public String getId() { | ||
return String.valueOf(attributes.get("id")); | ||
} | ||
|
||
@Override | ||
public String getNickname() { | ||
Map<String, Object> account = (Map<String, Object>) attributes.get("kakao_account"); | ||
Map<String, Object> profile = (Map<String, Object>) account.get("profile"); | ||
|
||
if (account == null || profile == null) { | ||
return null; | ||
} | ||
|
||
return (String) profile.get("nickname"); | ||
} | ||
|
||
@Override | ||
public String getImageUrl() { | ||
Map<String, Object> account = (Map<String, Object>) attributes.get("kakao_account"); | ||
Map<String, Object> profile = (Map<String, Object>) account.get("profile"); | ||
|
||
if (account == null || profile == null) { | ||
return null; | ||
} | ||
|
||
return (String) profile.get("thumbnail_image_url"); | ||
} | ||
|
||
@Override | ||
public String getEmail() { | ||
return (String) attributes.get("email"); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
InjeRecipe/src/main/java/com/example/injerecipe/oauth2/userinfo/NaverOAuth2UserInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.example.injerecipe.oauth2.userinfo; | ||
|
||
import java.util.Map; | ||
|
||
public class NaverOAuth2UserInfo extends OAuth2UserInfo { | ||
|
||
public NaverOAuth2UserInfo(Map<String, Object> attributes) { | ||
super(attributes); | ||
} | ||
|
||
@Override | ||
public String getId() { | ||
Map<String, Object> response = (Map<String, Object>) attributes.get("response"); | ||
|
||
if (response == null) { | ||
return null; | ||
} | ||
return (String) response.get("id"); | ||
} | ||
|
||
@Override | ||
public String getNickname() { | ||
Map<String, Object> response = (Map<String, Object>) attributes.get("response"); | ||
|
||
if (response == null) { | ||
return null; | ||
} | ||
|
||
return (String) response.get("nickname"); | ||
} | ||
|
||
@Override | ||
public String getImageUrl() { | ||
Map<String, Object> response = (Map<String, Object>) attributes.get("response"); | ||
|
||
if (response == null) { | ||
return null; | ||
} | ||
|
||
return (String) response.get("profile_image"); | ||
} | ||
|
||
@Override | ||
public String getEmail() { | ||
return (String) attributes.get("email"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,3 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>구글 로그인</title> | ||
</head> | ||
<body> | ||
<a href="/oauth2/authorization/google" class="btn btn-sm btn-success active" role="button">Google Login</a><br> | ||
|
||
</body> | ||
</html> | ||
<a href="/oauth2/authorization/kakao">Kakao Login</a><br> | ||
<a href="/oauth2/authorization/google">Google Login</a><br> | ||
<a href="/oauth2/authorization/naver">Naver Login</a><br> |