0

AWS Cognito Unity SDK를 사용하여 Facebook 로그인으로 사용자를 인증하고 싶습니다. InitCognito() 메소드가 실행되면, 나는 무단 신원 이드 (한 번 내가 같은 장치, 무단 식별 번호 변경에 대한이 응용 프로그램을 다시 설치) 얻을AWS Cognito를 사용하여 Facebook Id로 인증하는 방법은 무엇입니까?

void Start() 

{ 
    InitCognito(); 

} 
public void InitCognito() 
{ 
    UnityInitializer.AttachToGameObject (this.gameObject); 
    credentials = new CognitoAWSCredentials (
     identity_pool_id, // Identity Pool ID 
     region // Region 
    ); 

    Debug.Log ("identity_pool_id = " + identity_pool_id + " region = " + region); 

    credentials.GetIdentityIdAsync(delegate(AmazonCognitoIdentityResult<string> 
     result) { 
     if (result.Exception != null) { 
      Debug.LogError(result.Exception.ToString()); 
     } 
     string identityId = result.Response; 
     Debug.Log("identityId = "+identityId); 
     FBInit(); 
    }); 



} 



public void FBInit() 
{ 
    FB.Init(this.OnInitComplete, this.OnHideUnity); 
    Debug.Log("FB.Init() called with " + FB.AppId); 

} 

public void FBLogin() 
{ 

    FB.LogInWithReadPermissions(new List<string>() { "public_profile", "email", "user_friends" }, this.HandleResult); 

} 


private void OnInitComplete() 
{ 
    Debug.Log("Success - Check log for details"); 
    Debug.Log("Success Response: OnInitComplete Called\n"); 
    Debug.Log(string.Format(
     "OnInitCompleteCalled IsLoggedIn='{0}' IsInitialized='{1}'", 
     FB.IsLoggedIn, 
     FB.IsInitialized)); 

    if (AccessToken.CurrentAccessToken != null) 
    { 
     Debug.Log("Access token = "+AccessToken.CurrentAccessToken.ToString()); 
    } 
    FBLogin(); 
} 

private void OnHideUnity(bool isGameShown) 
{ 
    Debug.Log("Success - Check log for details"); 
    Debug.Log(string.Format("Success Response: OnHideUnity Called {0}\n", isGameShown)); 
    Debug.Log("Is game shown: " + isGameShown); 
} 
protected void HandleResult(IResult result) 
{ 
    if (result == null) 
    { 
     Debug.Log("Null Response\n"); 

     return; 
    } 



    // Some platforms return the empty string instead of null. 
    if (!string.IsNullOrEmpty(result.Error)) 
    { 
     Debug.Log("Error - Check log for details"); 
     Debug.Log("Error Response:\n" + result.Error); 
    } 
    else if (result.Cancelled) 
    { 
     Debug.Log ("Cancelled - Check log for details"); 
     Debug.Log("Cancelled Response:\n" + result.RawResult); 
    } 
    else if (!string.IsNullOrEmpty(result.RawResult)) 
    { 
     Debug.Log ("Success - Check log for details"); 
     Debug.Log ("Success Response:\n" + result.RawResult); 
     Debug.Log ("Access Token = "+AccessToken.CurrentAccessToken); 
     Debug.Log ("Access Token = "+AccessToken.CurrentAccessToken.TokenString); 
     Debug.Log ("Access User Id =" + AccessToken.CurrentAccessToken.UserId); 
     credentials.AddLogin ("graph.facebook.com", AccessToken.CurrentAccessToken.TokenString); 
     if (credentials.CurrentLoginProviders.Length > 0) { 
      Debug.Log (credentials.CurrentLoginProviders[0]); 
     } 

     Debug.Log (credentials.GetCachedIdentityId()); 
    } 
    else 
    { 
     Debug.Log ("Empty Response\n"); 
    } 


} 

:

이 내 코드입니다. 그러면 Facebook 사용자 ID와 토큰을 성공적으로 가져올 수 있습니다.

Cognito Developer Guide에 따라 credentials.AddLogin()을 사용하여 Facebook 로그인 정보를 추가하십시오. 그러나이 메소드가 실행 된 후 Debug.Log (credentials.GetCachedIdentityId())은 ID ID가 unauthorized Identity Id와 동일하고 Facebook Id로 참조 된 특정 ID가 아니라는 것을 보여줍니다. AWS Cognito 콘솔은 "Linked Login"이 없음을 보여줍니다. credentials.AddLogin()을 잘못된 방법으로 사용합니까?

감사합니다.

답변

0

로그인 토큰을 설정했다고해서 반드시 SDK가 서버로 보내는 것을 의미하지는 않습니다. 아래 명령을 실행 해 볼 수 있습니까? 강제해야합니까? 동일한 신원을 확인하는 이유는 서버를 변경 사항으로 업데이트하지 않았다는 것입니다. Cognito developer guide에서 가져 왔습니다.

credentials.GetIdentityIdAsync(delegate(AmazonCognitoIdentityResult<string> result) { 
    if (result.Exception != null) { 
     //Exception! 
    } 
    string identityId = result.Response; 
}); 
관련 문제