0

클라이언트에서 Facebook 로그인 및 AWS Cognito를 사용하여 인증 절차를 설정했습니다. dynambodb 테이블에 facebook id가있는 사용자의 참조가 필요하며 API 호출에 유효한 facebook id (이 Facebook ID가 AWS Cognito ID와 일치 함)가 있는지 확인하십시오. 이 답변에 대한 해결책을 찾았습니다 : AWS Cognito, Lambda, User credentials in DynamoDBAWS의 ID IDCognito 변경

그러나 동일한 장치에서 여러 번 Cognito로 로그인하면 콘솔에 몇 가지 다른 ID가 있음을 발견했습니다. 이와 같이 : screen shot

신원 ID는 특정 기기 ID가 특정 기기 ID 인 경우 고유하다고 생각했습니다. 실수를 하나합니까? ID가 변경되면 어떻게 페이스 북 사용자의 데이터를 DynamoDB에 저장할 수 있습니까? InitCognito() 메소드가 실행되면, 내가 (한 번 나는 같은 장치, 무단 식별 번호 변경에 대한이 응용 프로그램을 다시 설치)를 무단 식별 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와 토큰을 성공적으로 가져올 수 있습니다. credentials.AddLogin() 메소드가 실행 된 후, Debug.Log (credentials.GetCachedIdentityId())는 Identity Id가 Facebook ID로 참조 된 특정 ID가 아닌 unauthorized Identity Id와 동일 함을 보여줍니다. credentials.AddLogin()을 잘못된 방법으로 사용합니까?

감사합니다.

+1

이러한 ID를 클릭하십시오. 그들에게 로그인이 연결되어 있습니까? –

+0

두 명이 로그인을 연결했습니다. "링크 된 로그인"필드는 첫 번째 필드에 "graph.facebook.com"을 표시하고 두 번째 필드에는 "DISABLED us-east-1"을 표시합니다. – DogJunior

답변

1

여러 개의 ID가 표시되는 이유는 인증되지 않았기 때문입니다. 페이스 북 토큰을주지 않고도 많은 요청을하고 있습니다. 페이스 북 토큰을 가진 모든 요청은 동일한 인증 된 ID (위에서 언급 한 ID)를 제공하지만 토큰을 제공하려면 계속 제공해야합니다. 그것들은 고유 한 ID로 매핑되지만, 아무도없는 요청은 그렇지 않습니다.

+0

당신이 옳다고 생각합니다. 그러나 때때로 인증 된 ID는 인증되지 않은 ID와 동일합니다. 어쩌면 내 코드에 실수가있을 수 있습니다. 질문에 내 코드를 붙여 넣었습니다. 너 나 좀 도와 줄래? 고맙습니다! – DogJunior

+0

Jeff의 설명을 계속하려면 먼저 인증되지 않은 신원 identA를 얻으십시오. 서비스에 FB 토큰 및 idenA를 제공하면 idenA는 인증 된 ID가되므로 로그인을이 ID에 연결합니다. 다음 번에 FB 토큰을 제공하지 않으면 새로운 인증되지 않은 ID 인 idenB가 생깁니다. 현재 동일한 사용자에 대해 FB 토큰을 제공하면 idenA가 반환됩니다. FB 토큰이 다른 사용자에 속하면 idenB가 이제이 새 사용자에 연결됩니다. –

+0

후속 람다 호출의 경우 FB 토큰을 다시 전달합니까? 또는 FB 토큰과 idenA를 [??????] 서비스에 "제공하면"호출자에게 다시 전송하는 세션 토큰을 반환하고 호출자가 이후의 호출을 위해 해당 토큰을 보낼 것으로 예상합니까? 이것이 너무 n00b 인 경우 실제로 이것을 설명하는 내용을 가르쳐주세요. –