2015-01-03 4 views
0

AWS Cognito API를 사용하여 Swift로 작성된 iOS 앱이 있습니다. USEast1에 연결하면 예상대로 작동하고 특정 아무것도 지역으로, 내 사용자AWS Cognito 전용 USEast1에서 작업 중

var awsProperties = NSDictionary(contentsOfFile: NSBundle.mainBundle().pathForResource("AWS", ofType: "plist")!) 
var credentialsProvider : AWSCognitoCredentialsProvider 
var loggedIn = false 

override init() { 
    credentialsProvider = AWSCognitoCredentialsProvider.credentialsWithRegionType(
     AWSRegionType.USEast1, 
     accountId:awsProperties?.valueForKey(GlobalConstants.AccountId) as String, 
     identityPoolId:awsProperties?.valueForKey(GlobalConstants.USIdentityPoolId) as String, 
     unauthRoleArn:awsProperties?.valueForKey(GlobalConstants.UnauthDefaultRole) as String, 
     authRoleArn:awsProperties?.valueForKey(GlobalConstants.AuthDefaultRole) as String) 
} 

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool { 
    let defaultServiceConfiguration = AWSServiceConfiguration(
     region: AWSRegionType.USEast1, 
     credentialsProvider: credentialsProvider) 
    AWSServiceManager.defaultServiceManager().setDefaultServiceConfiguration(defaultServiceConfiguration) 
    credentialsProvider.getIdentityId().continueWithBlock { (task: BFTask!) -> AnyObject! in 
     if((task.error) != nil) { 
      NSLog("%@", task.error) 
     } else { 
      NSLog("%@", self.credentialsProvider.identityId) 
      self.loggedIn = true 
     } 
     return self.loggedIn 
    } 

    return true 
} 

내가 별도의 로그인 컨트롤러에서 G +에 대한 로그인을 허용하는 데 필요한 코드를 인증합니다.

나는 똑같은 코드,하지만를 사용하지만 경우 EUWest1에이 지역을 변경하고 내 유럽 연합 (EU) 나는 다음과 같은 예외가 얻을 풀을 식별 기반의 사용 :

AWSiOSSDKv2 [Error] AWSCredentialsProvider.m line:453 | __46-[AWSCognitoCredentialsProvider getIdentityId]_block_invoke | In refresh, but identityId is nil. 
AWSiOSSDKv2 [Error] AWSCredentialsProvider.m line:454 | __46-[AWSCognitoCredentialsProvider getIdentityId]_block_invoke | Result from getIdentityId is (null) 

내 IAM 역할에 대한 신뢰 정책 모두에 액세스 할 수 있습니다를 ID 풀 :

{ 
    "Version": "2012-10-17", 
    "Statement": [ 
    { 
     "Sid": "", 
     "Effect": "Allow", 
     "Principal": { 
     "Federated": "accounts.google.com" 
     }, 
     "Action": "sts:AssumeRoleWithWebIdentity", 
     "Condition": { 
     "StringEquals": { 
      "cognito-identity.amazonaws.com:aud": [ 
      "eu-west-1:XXXXXX", 
      "us-east-1:XXXXXX" 
      ] 
     }, 
     "ForAnyValue:StringLike": { 
      "cognito-identity.amazonaws.com:amr": "authenticated" 
     } 
     } 
    } 
    ] 
} 

내가이 영역을 재정의해야합니까?

답변

0

일반적으로 며칠 동안이 문제로 고민 끝에 마침내 SO에 게시 된 문제를 파악했습니다.

문제는 EUCentral1이없는 프레임 워크 검색 경로에 이전 버전의 AWS iOS SDK가 링크되어 있다는 것이 었습니다. 이 열거 형에 포함 된 것은 색인을 변경 한 것으로 보이며 Cognito가 USEast1 및 EUWest1에서만 지원되어 잘못된 지역에 대해 인증하려고 시도했기 때문입니다.

관련 문제