개발자 인증 자격 증명(자격 증명 풀) - Amazon Cognito

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

개발자 인증 자격 증명(자격 증명 풀)

Amazon Cognito는 페이스북을 아이덴티티 풀 IdP로 설정하기구글을 아이덴티티 풀 IdP로 설정하기, Amazon으로 로그인을 자격 증명 풀 IdP로 설정Apple을 자격 증명 풀 IdP로 사용하여 로그인 설정하기을 통한 웹 아이덴티티 페더레이션 외에 개발자 인증 자격 증명을 지원합니다. 개발자 인증 자격 증명을 사용하면 Amazon Cognito를 사용하여 사용자 데이터를 동기화하고 리소스에 액세스하면서 기존 인증 프로세스를 통해 사용자를 등록 및 인증할 수 있습니다. AWS 개발자 인증 자격 증명을 사용하려면 최종 사용자 디바이스, 인증을 위한 백엔드, Amazon Cognito 간의 상호 작용이 필요합니다. 자세한 내용은 블로그에서 Amazon Cognito 인증의 이해 2부: 개발자 인증 자격 증명을 참조하십시오. AWS

인증 흐름 이해

GetOpenIdTokenForDeveloperIdentityAPI 작업을 통해 고급 인증과 기본 인증 모두에 대한 개발자 인증을 시작할 수 있습니다. 이 API는 관리 자격 증명으로 요청을 인증합니다. Logins맵은 사용자 지정 식별자와 login.mydevprovider 짝을 이루는 것과 같은 자격 증명 풀 개발자 공급자 이름입니다.

예제

"Logins": { "login.mydevprovider": "my developer identifier" }

향상된 인증

토큰의 cognito-identity.amazonaws.com 이름과 값이 Logins 들어 있는 맵을 사용하여 GetCredentialsForIdentityAPI 작업을 GetOpenIdTokenForDeveloperIdentity 호출합니다.

예제

"Logins": { "cognito-identity.amazonaws.com": "eyJra12345EXAMPLE" }

GetCredentialsForIdentity개발자 인증 ID를 사용하면 자격 증명 풀의 기본 인증 역할에 대한 임시 자격 증명이 반환됩니다.

기본 인증

AssumeRoleWithWebIdentityAPI 작업을 호출하고 적절한 신뢰 관계가 RoleArn 정의된 IAM 역할을 요청합니다. 의 값을 에서 GetOpenIdTokenForDeveloperIdentity 가져온 WebIdentityToken 토큰으로 설정합니다.

개발자 인증 ID 인증 인증 흐름 및 외부 공급자 ID와 어떻게 다른지에 대한 자세한 내용은 을 참조하십시오. 자격 증명 풀(페더레이션 자격 증명) 인증 흐름

개발자 공급자 이름 정의 및 자격 증명 풀에 연결

개발자 인증 자격 증명을 사용하려면 개발자 공급자에 연결된 자격 증명 풀이 필요합니다. 이렇게 하려면 다음 단계를 따릅니다.

사용자 지정 개발자 공급자를 추가하려면
  1. Amazon Cognito 콘솔에서 자격 증명 풀을 선택합니다. 자격 증명 풀을 선택합니다.

  2. 사용자 액세스 탭을 선택합니다.

  3. ID 제공업체 추가를 선택합니다.

  4. 사용자 지정 개발자 공급자를 선택합니다.

  5. 개발자 공급자 이름을 입력합니다. 개발자 공급자는 추가 후에는 변경 또는 제거할 수 없습니다.

  6. 변경 사항 저장(Save changes)을 선택합니다.

참고: 공급자 이름을 설정하면 해당 이름을 변경할 수 없습니다.

Amazon Cognito 콘솔 작업에 대한 추가 지침은 Amazon Cognito 콘솔 사용 섹션을 참조하세요.

자격 증명 공급자 구현

Android

개발자 인증 자격 증명을 사용하려면 AWSAbstractCognitoIdentityProvider를 확장하는 고유한 ID 제공업체 클래스를 구현합니다. 자격 증명 공급자 클래스는 토큰이 속성으로 포함된 응답 객체를 반환해야 합니다.

다음은 ID 제공업체의 기본 예입니다.

public class DeveloperAuthenticationProvider extends AWSAbstractCognitoDeveloperIdentityProvider { private static final String developerProvider = "<Developer_provider_name>"; public DeveloperAuthenticationProvider(String accountId, String identityPoolId, Regions region) { super(accountId, identityPoolId, region); // Initialize any other objects needed here. } // Return the developer provider name which you choose while setting up the // identity pool in the &COG; Console @Override public String getProviderName() { return developerProvider; } // Use the refresh method to communicate with your backend to get an // identityId and token. @Override public String refresh() { // Override the existing token setToken(null); // Get the identityId and token by making a call to your backend // (Call to your backend) // Call the update method with updated identityId and token to make sure // these are ready to be used from Credentials Provider. update(identityId, token); return token; } // If the app has a valid identityId return it, otherwise get a valid // identityId from your backend. @Override public String getIdentityId() { // Load the identityId from the cache identityId = cachedIdentityId; if (identityId == null) { // Call to your backend } else { return identityId; } } }

이 자격 증명 공급자를 사용하려면 해당 공급자를 CognitoCachingCredentialsProvider에 전달해야 합니다. 다음은 그 예입니다.

DeveloperAuthenticationProvider developerProvider = new DeveloperAuthenticationProvider( null, "IDENTITYPOOLID", context, Regions.USEAST1); CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider( context, developerProvider, Regions.USEAST1);

iOS - Objective-C

개발자 인증 자격 증명을 사용하려면 AWSCognitoCredentialsProviderHelper를 확장하는 고유한 ID 제공업체 클래스를 구현합니다. 자격 증명 공급자 클래스는 토큰이 속성으로 포함된 응답 객체를 반환해야 합니다.

@implementation DeveloperAuthenticatedIdentityProvider /* * Use the token method to communicate with your backend to get an * identityId and token. */ - (AWSTask <NSString*> *) token { //Write code to call your backend: //Pass username/password to backend or some sort of token to authenticate user //If successful, from backend call getOpenIdTokenForDeveloperIdentity with logins map //containing "your.provider.name":"enduser.username" //Return the identity id and token to client //You can use AWSTaskCompletionSource to do this asynchronously // Set the identity id and return the token self.identityId = response.identityId; return [AWSTask taskWithResult:response.token]; } @end

이 자격 증명 공급자를 사용하려면 다음 예에 표시된 대로 해당 공급자를 AWSCognitoCredentialsProvider에 전달합니다.

DeveloperAuthenticatedIdentityProvider * devAuth = [[DeveloperAuthenticatedIdentityProvider alloc] initWithRegionType:AWSRegionYOUR_IDENTITY_POOL_REGION identityPoolId:@"YOUR_IDENTITY_POOL_ID" useEnhancedFlow:YES identityProviderManager:nil]; AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionYOUR_IDENTITY_POOL_REGION identityProvider:devAuth];

미인증 자격 증명과 개발자 인증 자격 증명을 모두 지원하려면 AWSCognitoCredentialsProviderHelper 구현에서 logins 메서드를 무시합니다.

- (AWSTask<NSDictionary<NSString *, NSString *> *> *)logins { if(/*logic to determine if user is unauthenticated*/) { return [AWSTask taskWithResult:nil]; }else{ return [super logins]; } }

개발자 인증 자격 증명 및 소셜 공급자를 지원하려면 AWSCognitoCredentialsProviderHelper의 logins 구현에서 현재 공급자가 누구인지 관리해야 합니다.

- (AWSTask<NSDictionary<NSString *, NSString *> *> *)logins { if(/*logic to determine if user is unauthenticated*/) { return [AWSTask taskWithResult:nil]; }else if (/*logic to determine if user is Facebook*/){ return [AWSTask taskWithResult: @{ AWSIdentityProviderFacebook : [FBSDKAccessToken currentAccessToken] }]; }else { return [super logins]; } }

iOS - Swift

개발자 인증 자격 증명을 사용하려면 AWSCognitoCredentialsProviderHelper를 확장하는 고유한 ID 제공업체 클래스를 구현합니다. 자격 증명 공급자 클래스는 토큰이 속성으로 포함된 응답 객체를 반환해야 합니다.

import AWSCore /* * Use the token method to communicate with your backend to get an * identityId and token. */ class DeveloperAuthenticatedIdentityProvider : AWSCognitoCredentialsProviderHelper { override func token() -> AWSTask<NSString> { //Write code to call your backend: //pass username/password to backend or some sort of token to authenticate user, if successful, //from backend call getOpenIdTokenForDeveloperIdentity with logins map containing "your.provider.name":"enduser.username" //return the identity id and token to client //You can use AWSTaskCompletionSource to do this asynchronously // Set the identity id and return the token self.identityId = resultFromAbove.identityId return AWSTask(result: resultFromAbove.token) }

이 자격 증명 공급자를 사용하려면 다음 예에 표시된 대로 해당 공급자를 AWSCognitoCredentialsProvider에 전달합니다.

let devAuth = DeveloperAuthenticatedIdentityProvider(regionType: .YOUR_IDENTITY_POOL_REGION, identityPoolId: "YOUR_IDENTITY_POOL_ID", useEnhancedFlow: true, identityProviderManager:nil) let credentialsProvider = AWSCognitoCredentialsProvider(regionType: .YOUR_IDENTITY_POOL_REGION, identityProvider:devAuth) let configuration = AWSServiceConfiguration(region: .YOUR_IDENTITY_POOL_REGION, credentialsProvider:credentialsProvider) AWSServiceManager.default().defaultServiceConfiguration = configuration

미인증 자격 증명과 개발자 인증 자격 증명을 모두 지원하려면 AWSCognitoCredentialsProviderHelper 구현에서 logins 메서드를 무시합니다.

override func logins () -> AWSTask<NSDictionary> { if(/*logic to determine if user is unauthenticated*/) { return AWSTask(result:nil) }else { return super.logins() } }

개발자 인증 자격 증명 및 소셜 공급자를 지원하려면 AWSCognitoCredentialsProviderHelper의 logins 구현에서 현재 공급자가 누구인지 관리해야 합니다.

override func logins () -> AWSTask<NSDictionary> { if(/*logic to determine if user is unauthenticated*/) { return AWSTask(result:nil) }else if (/*logic to determine if user is Facebook*/){ if let token = AccessToken.current?.authenticationToken { return AWSTask(result: [AWSIdentityProviderFacebook:token]) } return AWSTask(error:NSError(domain: "Facebook Login", code: -1 , userInfo: ["Facebook" : "No current Facebook access token"])) }else { return super.logins() } }

JavaScript

백엔드에서 자격 증명 ID 및 세션 토큰을 가져온 경우 이를 AWS.CognitoIdentityCredentials 공급자에 전달합니다. 다음은 그 예입니다.

AWS.config.credentials = new AWS.CognitoIdentityCredentials({ IdentityPoolId: 'IDENTITY_POOL_ID', IdentityId: 'IDENTITY_ID_RETURNED_FROM_YOUR_PROVIDER', Logins: { 'cognito-identity.amazonaws.com': 'TOKEN_RETURNED_FROM_YOUR_PROVIDER' } });

Unity

개발자 인증 자격 증명을 사용하려면 CognitoAWSCredentials를 확장하고 RefreshIdentity 메서드를 무시하여 백엔드에서 사용자 자격 증명 ID와 토큰을 검색하고 이를 반환해야 합니다. 다음은 'example.com'의 가상 백엔드에 접촉하는 ID 제공업체의 간단한 예입니다.

using UnityEngine; using System.Collections; using Amazon.CognitoIdentity; using System.Collections.Generic; using ThirdParty.Json.LitJson; using System; using System.Threading; public class DeveloperAuthenticatedCredentials : CognitoAWSCredentials { const string PROVIDER_NAME = "example.com"; const string IDENTITY_POOL = "IDENTITY_POOL_ID"; static readonly RegionEndpoint REGION = RegionEndpoint.USEast1; private string login = null; public DeveloperAuthenticatedCredentials(string loginAlias) : base(IDENTITY_POOL, REGION) { login = loginAlias; } protected override IdentityState RefreshIdentity() { IdentityState state = null; ManualResetEvent waitLock = new ManualResetEvent(false); MainThreadDispatcher.ExecuteCoroutineOnMainThread(ContactProvider((s) => { state = s; waitLock.Set(); })); waitLock.WaitOne(); return state; } IEnumerator ContactProvider(Action<IdentityState> callback) { WWW www = new WWW("http://example.com/?username="+login); yield return www; string response = www.text; JsonData json = JsonMapper.ToObject(response); //The backend has to send us back an Identity and a OpenID token string identityId = json["IdentityId"].ToString(); string token = json["Token"].ToString(); IdentityState state = new IdentityState(identityId, PROVIDER_NAME, token, false); callback(state); } }

위의 코드는 스레드 디스패처 객체를 사용하여 코루틴을 호출합니다. 프로젝트에서 이 작업을 수행할 방법이 없는 경우 장면에서 다음 스크립트를 사용할 수 있습니다.

using System; using UnityEngine; using System.Collections; using System.Collections.Generic; public class MainThreadDispatcher : MonoBehaviour { static Queue<IEnumerator> _coroutineQueue = new Queue<IEnumerator>(); static object _lock = new object(); public void Update() { while (_coroutineQueue.Count > 0) { StartCoroutine(_coroutineQueue.Dequeue()); } } public static void ExecuteCoroutineOnMainThread(IEnumerator coroutine) { lock (_lock) { _coroutineQueue.Enqueue(coroutine); } } }

Xamarin

개발자 인증 자격 증명을 사용하려면 CognitoAWSCredentials를 확장하고 RefreshIdentity 메서드를 무시하여 백엔드에서 사용자 자격 증명 ID와 토큰을 검색하고 이를 반환해야 합니다. 다음은 'example.com'의 가상 백엔드에 접촉하는 ID 제공업체의 기본 예입니다.

public class DeveloperAuthenticatedCredentials : CognitoAWSCredentials { const string PROVIDER_NAME = "example.com"; const string IDENTITY_POOL = "IDENTITY_POOL_ID"; static readonly RegionEndpoint REGION = RegionEndpoint.USEast1; private string login = null; public DeveloperAuthenticatedCredentials(string loginAlias) : base(IDENTITY_POOL, REGION) { login = loginAlias; } protected override async Task<IdentityState> RefreshIdentityAsync() { IdentityState state = null; //get your identity and set the state return state; } }

로그인 맵 업데이트(Android 및 iOS 전용)

Android

인증 시스템을 통해 사용자를 성공적으로 인증한 후 개발자 공급자 이름 및 개발자 사용자 식별자로 로그인 맵을 업데이트합니다. 이것은 인증 시스템에서 사용자를 고유하게 식별하는 영숫자 문자열입니다. refresh가 변경되었을 수 있으므로 로그인 맵을 업데이트한 후 identityId 메서드를 호출해야 합니다.

HashMap<String, String> loginsMap = new HashMap<String, String>(); loginsMap.put(developerAuthenticationProvider.getProviderName(), developerUserIdentifier); credentialsProvider.setLogins(loginsMap); credentialsProvider.refresh();

iOS - Objective-C

iOS SDK는 자격 증명이 없거나 만료된 경우 logins 메서드만 호출하여 최신 로그인 맵을 가져옵니다. SDK에서 새 자격 증명을 얻도록 강제하려면(예를 들어 최종 사용자가 미인증 상태에서 인증 상태로 변경되었으며 인증된 사용자에 대한 자격 증명을 원하는 경우) credentialsProvider에 대해 clearCredentials를 호출하세요.

[credentialsProvider clearCredentials];

iOS - Swift

iOS SDK는 자격 증명이 없거나 만료된 경우 logins 메서드만 호출하여 최신 로그인 맵을 가져옵니다. SDK에서 새 자격 증명을 얻도록 강제하려면(예: 최종 사용자가 미인증 상태에서 인증 상태로 변경되었으며 인증된 사용자에 대한 자격 증명을 원하는 경우) clearCredentials에 대해 credentialsProvider를 호출하세요.

credentialsProvider.clearCredentials()

토큰 가져오기(서버 측)

GetOpenIdTokenForDeveloperIdentity호출하여 토큰을 얻습니다. 이 API는 AWS 개발자 자격 증명을 사용하여 백엔드에서 호출해야 합니다. 클라이언트 SDK에서 호출해서는 안 됩니다. API는 Cognito 자격 증명 풀 ID, ID 제공업체 이름이 키로, 식별자가 값으로 포함된 로그인 맵 및 필요할 경우 Cognito 자격 증명 ID를 받습니다(예를 들어 미인증 사용자를 인증된 사용자로 변경하는 경우). 식별자는 사용자의 사용자 이름, 이메일 주소 또는 숫자 값일 수 있습니다. API는 사용자에 대한 고유한 Cognito ID와 최종 사용자에 대한 OpenID Connect 토큰을 사용하여 호출에 응답합니다.

GetOpenIdTokenForDeveloperIdentity에 의해 반환된 토큰에 대해 유의해야 할 몇 가지 사항은 다음과 같습니다.

  • 캐시할 수 있도록 토큰에 대한 사용자 지정 만료 시간을 지정할 수 있습니다. 사용자 지정 만료 시간을 제공하지 않으면 토큰은 15분 동안 유효합니다.

  • 설정할 수 있는 최대 토큰 지속 시간은 24시간입니다.

  • 토큰 지속 시간의 증가에 따른 보안 영향을 주의하세요. 공격자가 이 토큰을 획득하면 토큰 기간 동안 이를 최종 사용자의 AWS 자격 증명으로 교환할 수 있습니다.

다음 Java 조각은 Amazon Cognito 클라이언트를 초기화하고 개발자 인증 자격 증명의 토큰을 검색하는 방법을 보여 줍니다.

// authenticate your end user as appropriate // .... // if authenticated, initialize a cognito client with your AWS developer credentials AmazonCognitoIdentity identityClient = new AmazonCognitoIdentityClient( new BasicAWSCredentials("access_key_id", "secret_access_key") ); // create a new request to retrieve the token for your end user GetOpenIdTokenForDeveloperIdentityRequest request = new GetOpenIdTokenForDeveloperIdentityRequest(); request.setIdentityPoolId("YOUR_COGNITO_IDENTITY_POOL_ID"); request.setIdentityId("YOUR_COGNITO_IDENTITY_ID"); //optional, set this if your client has an //identity ID that you want to link to this //developer account // set up your logins map with the username of your end user HashMap<String,String> logins = new HashMap<>(); logins.put("YOUR_IDENTITY_PROVIDER_NAME","YOUR_END_USER_IDENTIFIER"); request.setLogins(logins); // optionally set token duration (in seconds) request.setTokenDuration(60 * 15l); GetOpenIdTokenForDeveloperIdentityResult response = identityClient.getOpenIdTokenForDeveloperIdentity(request); // obtain identity id and token to return to your client String identityId = response.getIdentityId(); String token = response.getToken(); //code to return identity id and token to client //...

앞의 단계에 따라 앱에 개발자 인증 자격 증명을 통합할 수 있어야 합니다. 문제나 질문이 있는 경우 자유롭게 포럼에 게시해 주세요.

기존 소셜 자격 증명에 연결

개발자 인증 자격 증명을 사용할 때 백엔드에서 모든 공급자 연결이 수행되어야 합니다. 사용자 지정 ID를 사용자의 소셜 ID (Amazon으로 로그인, Apple, Facebook 또는 Google로 로그인) 에 연결하려면 전화를 걸 GetOpenIdTokenForDeveloperIdentity때 로그인 맵에 ID 공급자 토큰을 추가하십시오. 이렇게 하려면 클라이언트 SDK에서 백엔드를 호출하여 최종 사용자를 인증할 때 최종 사용자의 소셜 공급자 토큰을 추가로 전달하세요.

예를 들어, 사용자 지정 자격 증명을 Facebook에 연결하려고 시도할 경우 GetOpenIdTokenForDeveloperIdentity를 호출할 때 로그인 맵에 자격 증명 공급자 식별자 이외에 Facebook 토큰도 추가합니다.

logins.put("YOUR_IDENTITY_PROVIDER_NAME","YOUR_END_USER_IDENTIFIER"); logins.put("graph.facebook.com","END_USERS_FACEBOOK_ACCESSTOKEN");

공급자 간 전환 지원

Android

애플리케이션에는 개발자 인증 자격 증명과 함께 퍼블릭 공급자(Login with Amazon, Sign in with Apple, Facebook 또는 Google)를 사용한 미인증 자격 증명 또는 인증 자격 증명 지원이 필요할 수 있습니다. 개발자 인증 자격 증명과 다른 자격 증명(퍼블릭 공급자를 사용하는 미인증 자격 증명 및 인증 자격 증명) 간의 본질적인 차이점은 identityId 및 토큰을 얻는 방식입니다. 다른 자격 증명의 경우 모바일 애플리케이션은 인증 시스템과 접촉하는 대신 Amazon Cognito와 직접 상호 작용합니다. 따라서 모바일 애플리케이션은 앱 사용자가 선택한 사항에 따라 두 개의 고유 흐름을 지원할 수 있어야 합니다. 이를 위해 사용자 지정 ID 제공업체를 일부 변경해야 합니다.

refresh 메서드는 로그인 맵을 확인합니다. 맵이 비어 있지 않고 개발자 공급자 이름이 포함된 키가 있는 경우, 백엔드를 호출합니다. 그렇지 않으면 getIdentityId 메서드를 호출하고 null을 반환합니다.

public String refresh() { setToken(null); // If the logins map is not empty make a call to your backend // to get the token and identityId if (getProviderName() != null && !this.loginsMap.isEmpty() && this.loginsMap.containsKey(getProviderName())) { /** * This is where you would call your backend **/ // now set the returned identity id and token in the provider update(identityId, token); return token; } else { // Call getIdentityId method and return null this.getIdentityId(); return null; } }

마찬가지로 getIdentityId 메서드에도 로그인 맵의 내용에 따라 두 개의 흐름이 있습니다.

public String getIdentityId() { // Load the identityId from the cache identityId = cachedIdentityId; if (identityId == null) { // If the logins map is not empty make a call to your backend // to get the token and identityId if (getProviderName() != null && !this.loginsMap.isEmpty() && this.loginsMap.containsKey(getProviderName())) { /** * This is where you would call your backend **/ // now set the returned identity id and token in the provider update(identityId, token); return token; } else { // Otherwise call &COG; using getIdentityId of super class return super.getIdentityId(); } } else { return identityId; } }

iOS - Objective-C

애플리케이션에는 개발자 인증 자격 증명과 함께 퍼블릭 공급자(Login with Amazon, Sign in with Apple, Facebook 또는 Google)를 사용한 미인증 자격 증명 또는 인증 자격 증명 지원이 필요할 수 있습니다. 이렇게 하려면 현재 ID 공급자를 기반으로 올바른 로그인 맵을 반환할 수 있도록 AWSCognitoCredentialsProviderHelperlogins메서드를 재정의하십시오. 이 예는 미인증, Facebook, 개발자 인증 간 피벗할 수 있는 방법을 보여 줍니다.

- (AWSTask<NSDictionary<NSString *, NSString *> *> *)logins { if(/*logic to determine if user is unauthenticated*/) { return [AWSTask taskWithResult:nil]; }else if (/*logic to determine if user is Facebook*/){ return [AWSTask taskWithResult: @{ AWSIdentityProviderFacebook : [FBSDKAccessToken currentAccessToken] }]; }else { return [super logins]; } }

미인증 상태에서 인증 상태로 전환하면 [credentialsProvider clearCredentials];를 호출하여 SDK에서 새 인증 자격 증명을 얻도록 강제해야 합니다. 두 인증 공급자 간에 전환하고 두 공급자를 연결하려고 하지 않는 경우(예를 들어 로그인 딕셔너리에서 여러 공급자에 대한 토큰을 제공하지 않는 경우) [credentialsProvider clearKeychain];을 호출해야 합니다. 이렇게 하면 자격 증명이 모두 지워지고 SDK가 새 자격 증명을 얻도록 강제하게 됩니다.

iOS - Swift

애플리케이션에는 개발자 인증 자격 증명과 함께 퍼블릭 공급자(Login with Amazon, Sign in with Apple, Facebook 또는 Google)를 사용한 미인증 자격 증명 또는 인증 자격 증명 지원이 필요할 수 있습니다. 이렇게 하려면 현재 ID 제공자를 기반으로 올바른 로그인 맵을 반환할 수 있도록 AWSCognitoCredentialsProviderHelperlogins메서드를 재정의하십시오. 이 예는 미인증, Facebook, 개발자 인증 간 피벗할 수 있는 방법을 보여 줍니다.

override func logins () -> AWSTask<NSDictionary> { if(/*logic to determine if user is unauthenticated*/) { return AWSTask(result:nil) }else if (/*logic to determine if user is Facebook*/){ if let token = AccessToken.current?.authenticationToken { return AWSTask(result: [AWSIdentityProviderFacebook:token]) } return AWSTask(error:NSError(domain: "Facebook Login", code: -1 , userInfo: ["Facebook" : "No current Facebook access token"])) }else { return super.logins() } }

미인증 상태에서 인증 상태로 전환하면 credentialsProvider.clearCredentials()를 호출하여 SDK에서 새 인증 자격 증명을 얻도록 강제해야 합니다. 두 인증 공급자 간에 전환하고 두 공급자를 연결하려고 하지 않는 경우(즉, 로그인 딕셔너리에서 여러 공급자에 대한 토큰을 제공하지 않는 경우) credentialsProvider.clearKeychain()을 호출해야 합니다. 이렇게 하면 자격 증명이 모두 지워지고 SDK가 새 자격 증명을 얻도록 강제하게 됩니다.

Unity

애플리케이션에는 개발자 인증 자격 증명과 함께 퍼블릭 공급자(Login with Amazon, Sign in with Apple, Facebook 또는 Google)를 사용한 미인증 자격 증명 또는 인증 자격 증명 지원이 필요할 수 있습니다. 개발자 인증 자격 증명과 다른 자격 증명(퍼블릭 공급자를 사용하는 미인증 자격 증명 및 인증 자격 증명) 간의 본질적인 차이점은 identityId 및 토큰을 얻는 방식입니다. 다른 자격 증명의 경우 모바일 애플리케이션은 인증 시스템과 접촉하는 대신 Amazon Cognito와 직접 상호 작용합니다. 모바일 애플리케이션은 앱 사용자가 선택한 사항에 따라 두 개의 고유 흐름을 지원할 수 있어야 합니다. 이를 위해 사용자 지정 자격 증명 공급자를 일부 변경해야 합니다.

Unity에서 이 작업을 수행하는 권장 방법은 AmazonCognitoEnhancedIdentityProvide 대신 에서 ID 공급자를 확장하고 AbstractCognitoIdentityProvider, 사용자가 자체 백엔드로 인증되지 않은 경우 자체 RefreshAsync 메서드 대신 부모 메서드를 호출하는 것입니다. 사용자가 인증 상태이면 이전에 설명한 것과 동일한 흐름을 사용할 수 있습니다.

Xamarin

애플리케이션에는 개발자 인증 자격 증명과 함께 퍼블릭 공급자(Login with Amazon, Sign in with Apple, Facebook 또는 Google)를 사용한 미인증 자격 증명 또는 인증 자격 증명 지원이 필요할 수 있습니다. 개발자 인증 자격 증명과 다른 자격 증명(퍼블릭 공급자를 사용하는 미인증 자격 증명 및 인증 자격 증명) 간의 본질적인 차이점은 identityId 및 토큰을 얻는 방식입니다. 다른 자격 증명의 경우 모바일 애플리케이션은 인증 시스템과 접촉하는 대신 Amazon Cognito와 직접 상호 작용합니다. 모바일 애플리케이션은 앱 사용자가 선택한 사항에 따라 두 개의 고유 흐름을 지원할 수 있어야 합니다. 이를 위해 사용자 지정 ID 제공업체를 일부 변경해야 합니다.