App/Android

[Android Studio] Google 로그인 인증(2)

soyeon26 2019. 8. 18. 10:56

[Android Studio] Google 로그인 인증(1)에 에서 Android Studio에 Firebase 기능을 추가했다면 이제 본격적으로 인증 기능을 넣을 것이다.

 

https://firebase.google.com/docs/auth/android/google-signin?authuser=0

 

Android에서 Google 로그인을 사용하여 인증하기  |  Firebase

앱에 Google 로그인을 통합하여 사용자가 Google 계정을 통해 Firebase에 인증하도록 할 수 있습니다. 시작하기 전에 아직 추가하지 않았다면 Android 프로젝트에 Firebase를 추가합니다. 프로젝트 수준 build.gradle 파일의 buildscript 및 allprojects 섹션에 Google의 Maven 저장소가 포함되어야 합니다. 다음과 같이 모듈(앱 수준) Gradle 파일(일반적으로 app/build.gradle)에 Fir

firebase.google.com

 


 

다음과 같이 모듈(앱 수준) Gradle 파일(일반적으로 app/build.gradle)에 Firebase 인증 Android 라이브러리 및 Google Play 서비스 종속 항목을 추가합니다.

 

입력 한 후 반드시 Sync Now누르기!

implementation 'com.google.firebase:firebase-auth:18.0.0'
implementation 'com.google.android.gms:play-services-auth:17.0.0'

 

그 다음 Firebase 콘솔로 이동해 Authentication에 들어간 다음 로그인 방법 탭에서 Google 로그인 방법을 사용 설정하고 저장을 클릭합니다.

 

로그인 방법 설정 누르기!

 

 

사용 설정됨으로 해줘야한다.

 

 


 

이렇게 모두 설정이 됐다면 Android StudioxmlSign in button을 만들어 준다.

 

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <com.google.android.gms.common.SignInButton
        android:id="@+id/signin_btn"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    </com.google.android.gms.common.SignInButton>
    
</RelativeLayout>

 

이렇게 SingInButton을 만들어 주고 preview를 확인해보면
짜잔! 이렇게 Google 인증 버튼이 만들어져 있다!

 

 

2019/08/18 - [Android ] - [Android Studio] Google 로그인 인증 (3)

 

[Android Studio] Google 로그인 인증 (3)

https://firebase.google.com/docs/auth/android/google-signin?authuser=0 Android에서 Google 로그인을 사용하여 인증하기 | Firebase 앱에 Google 로그인을 통합하여 사용자가 Google 계정을 통해 Firebase에..

sy-blog.tistory.com