-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
iOS 기기에서 애플 로그인 시 LoginType뿐만 아니라 RawNonce를 매개변수로 추가할 수 있을까요?
firebase auth 와 연동하려면 임의의 랜덤 RawNonce를 url에 함께 추가해서 보내고 firebase credential 에 같은 RawNonce를 공유해야 합니다. RawNonce없이 애플 로그인 요청을 하면 firebase auth 연동이 실패됩니다.
아래 코드는 Android 기기에서 애플 로그인하고 firebase auth와 연동이 성공한 코드입니다.
public void SignInApple()
{
_rawNonce = NonceGenerator.GenerateRawNonce();
string hashedNonce = NonceGenerator.HashNonceSHA256(_rawNonce);
string state = Guid.NewGuid().ToString();
string url =
"https://appleid.apple.com/auth/authorize" +
"?response_type=code%20id_token" +
"&response_mode=form_post" +
"&client_id=" + Uri.EscapeDataString(_appleServiceId) +
"&redirect_uri=" + Uri.EscapeDataString(_appleRedirectUri) +
"&scope=name%20email" +
"&nonce=" + hashedNonce +
"&state=" + state;
UniversalSDK.Ins.OpenCustomTabView(url);
}
private void SignInFirebaseWithApple(string idToken)
{
var credential = OAuthProvider.GetCredential("apple.com", idToken, _rawNonce, null);
_auth.SignInWithCredentialAsync(credential).ContinueWith(task =>
{
if (task.IsCompleted && !task.IsFaulted)
{
OnLoginSuccess(task.Result);
}
else
{
Debug.LogError(task.Exception?.ToString());
}
});
}이처럼 url에 _rawNonce를 집어넣고 credential을 만들 때 _rawNonce를 넣어야 firebase와 연동이 성공합니다.
https://github.com/lupidan/apple-signin-unity/blob/master/docs/Firebase_NOTES.md
이걸 보시면 더 이해하는데 도움이 되실 겁니다.
Android에서 google, apple 로그인과 iOS에서 google, apple 로그인 모두 잘 되고 iOS에서 apple 로그인 빼고 다른 경우와 firebase연동 또한 원활하게 되어 감사하게 잘 사용하고 있습니다.
이 문제만 해결되면 완전해질 것 같습니다!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels