[android] Google Sign In 서버로 검증하기 #3
https://developers.google.com/identity/sign-in/android/backend-auth
-
Client 에서 Sign in 이 끝나면 user의 ID token 을 HTTPS 를 통해 서버로 보낸다.
Server 에서는 ID token 을 이용해 검증한다.
이 때 절대 Account 정보에서 얻어오는 id 정보가 아니라,
ID token 을 보내야 한다.
-
ID Token 을 가져오기 위해서는 GoogleSignInOptions 를 만들 때 requestIdToken 을 호출해야 한다.
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(getString(R.string.server_client_id)) // serverClientId 는 json 파일에 들어 있다.
.build();
-
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
if (result.isSuccess()) {
GoogleSignInAccount acct = result.getSignInAccount();
String idToken = acct.getIdToken();
// TODO send idToken to server
}
-
Verify 는 서버의 몫!!
'프로그래밍 놀이터 > 안드로이드, Java' 카테고리의 다른 글
[android] Direct Reply Tutorial (0) | 2018.02.28 |
---|---|
[android] App Shortcuts Tutorial (0) | 2018.02.25 |
[android] Google Sign In 코드 짜기 #2 (0) | 2018.02.23 |
[android] Google Sign In 준비하기 #1 (2) | 2018.02.22 |
[android] odex 에 대해 알아보자. (0) | 2018.01.24 |
댓글