본문으로 건너뛰기
버전: SDK-5.11.4

GoogleLogin

정보

구글 로그인 코드는 GoogleLogin과 OnGoogleLogin 코드가 모두 구현되어 있어야하며, OnGoogleLogin이 GoogleLogin 호출보다 먼저 설정되어야합니다.

public bool GoogleLogin(string webClientId, out string errorMessage);

파라미터

ValueTypeDescription
webClientIdstring구글 클라우드 플랫폼에서 설정한 웹 ClientID
errorMessageString성공 시, 빈 값 / 실패 시, 에러정보

구글 로그인을 시도합니다. 결과는 OnGoogleLogin 콜백 이벤트를 통해 확인할 수 있습니다.

Example

public void StartGoogleLogin()
{
#if UNITY_ANDROID
string message;
var result = BackendFederation.Android.GoogleLogin("123456789-abcdefghigkelnop12351.apps.googleusercontent.com", out message);
if (result == false)
{
Debug.LogError(message);
}
#endif
}

ReturnCase

Success cases

구글 로그인 호출에 성공한 경우
이 상태는 단순히 구글 로그인에 성공한 것이 아니며 onGetAccessToken의 결과값을 통해 로그인의 성공 여부를 확인할 수 있습니다.
true
errorInfo : ErrorInfo.Success

Error cases

실행 기기가 Android가 아닐 경우
false
errorMessage : "not support os: [ platform ]"


OnGoogleLogin

public void OnGoogleLogin(bool isSuccess, string errorMessage, string token);

ValueTypeDescription
isSuccessbool구글 로그인 성공 여부
errorMessageString성공 시, 빈 값 / 실패 시, 에러정보
tokenString성공 시, 구글 로그인에 사용할 token / 실패 시, 빈 값

설명

GoogleLogin 함수를 호출한 후 리턴되는 콜백을 등록합니다.
해당 콜백 내에서 구글 로그인이 성공했는지 확인할 수 있으며, 성공하였을 경우 token이 리턴됩니다.

이후 해당 토큰을 이용하여 페더레이션 로그인을 진행하실 수 있습니다.

Example

void Start()
{
#if UNITY_ANDROID
//구글 로그인 호출 후에 결과를알려주는 콜백 등록
BackendFederation.Android.OnGoogleLogin += (bool isSuccess, string errorMessage, string token) =>
{
if (isSuccess == false)
{
Debug.LogError(errorMessage);
return;
}
var loginBro = Backend.BMember.AuthorizeFederation(token, FederationType.Google);
Debug.Log("로그인 결과 : " + loginBro);
};
#endif
}

Error cases

구글 클라우드 플랫폼에서 설정한 정보가 잘못되어있을 경우
bool : false
errorMessage : "GoogleLogin Failed. Reason : 10: "(10:는 구글 SDK에서 리턴되는 에러메시지입니다.)

테스터로 로그인을 시도하지 않았을 경우(프로덕션 단계는 제외)
bool : false
errorMessage : "GoogleLogin Failed. Reason : 10: "(10:는 구글 SDK에서 리턴되는 에러메시지입니다.)

올바르지 않은 webClientID를 사용하였을 경우
bool : false
errorMessage : "GoogleLogin Failed. Reason : 10: "(10:는 구글 SDK에서 리턴되는 에러메시지입니다.)