[英]AWS Cognito: “Unauthenticated access is not supported for this identity pool.”
i am fighting with an issue "Unauthenticated access is not supported for this identity pool."
我正在解决一个问题
"Unauthenticated access is not supported for this identity pool."
from AWS Cognito in my Swift iOS Application. 来自我的Swift iOS应用程序中的AWS Cognito。 I previously used Firebase for authentication & storage and have decided to migrate to AWS Mobile Hud for reasons outside the scope of this question.
我以前使用Firebase进行身份验证和存储,并且已决定迁移到AWS Mobile Hud,原因超出了此问题的范围。
I use / have set up: 我用/已设置:
I downloaded the sample app generated for my project and run it. 我下载了为我的项目生成的示例应用程序并运行它。
Through the sample app, I am able to successfully register / authenticate through Facebook and Cognito.
通过示例应用程序,我能够通过Facebook和Cognito成功注册/验证。
What works?: I have integrated all SDK/Frameworks of AWS into my project and am able to build successfully (note: all AWS frameworks are integrated through cocoapods, except 'AWSMobileHubHelper' as a static framework). 什么有效?:我已经将AWS的所有SDK /框架集成到我的项目中并且能够成功构建(注意:所有AWS框架都通过cocoapod集成,除了'AWSMobileHubHelper'作为静态框架)。
I can build the app and it opens
我可以构建应用程序并打开它
What does not work?: The app crashes immediately after opening up with the following crash log: 什么不起作用?:使用以下崩溃日志打开后,应用程序立即崩溃:
2017-02-13 15:43:49.825 dates[19823:463495] AWSiOSSDK v2.5.0 [Debug] AWSURLSessionManager.m line:566 | -[AWSURLSessionManager printHTTPHeadersForResponse:] | Response headers:
{
Connection = "keep-alive";
"Content-Length" = 111;
"Content-Type" = "application/x-amz-json-1.1";
Date = "Mon, 13 Feb 2017 14:43:49 GMT";
"x-amzn-ErrorMessage" = "Unauthenticated access is not supported for this identity pool.";
"x-amzn-ErrorType" = "NotAuthorizedException:";
"x-amzn-RequestId" = "d4f8ec82-f1fa-11e6-bd81-3727ca129d86";
}
2017-02-13 15:43:49.826 dates[19823:463495] AWSiOSSDK v2.5.0 [Debug] AWSURLResponseSerialization.m line:63 | -[AWSJSONResponseSerializer responseObjectForResponse:originalRequest:currentRequest:data:error:] | Response body:
{"__type":"NotAuthorizedException","message":"Unauthenticated access is not supported for this identity pool."}
2017-02-13 15:43:49.826 dates[19823:463495] AWSiOSSDK v2.5.0 [Error] AWSIdentityProvider.m line:309 | __52-[AWSCognitoCredentialsProviderHelper getIdentityId]_block_invoke.255 | GetId failed. Error is [Error Domain=com.amazonaws.AWSCognitoIdentityErrorDomain Code=8 "(null)" UserInfo={__type=NotAuthorizedException, message=Unauthenticated access is not supported for this identity pool.}]
2017-02-13 15:43:49.826 dates[19823:463452] AWSiOSSDK v2.5.0 [Error] AWSCredentialsProvider.m line:565 | __44-[AWSCognitoCredentialsProvider credentials]_block_invoke.349 | Unable to refresh. Error is [Error Domain=com.amazonaws.AWSCognitoIdentityErrorDomain Code=8 "(null)" UserInfo={__type=NotAuthorizedException, message=Unauthenticated access is not supported for this identity pool.}]
2017-02-13 15:43:49.827 dates[19823:463379] -[AWSTask exception]: unrecognized selector sent to instance 0x60800027af00
2017-02-13 15:43:49.828 dates[19823:463379] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AWSTask exception]: unrecognized selector sent to instance 0x60800027af00'
*** First throw call stack:
(
0 CoreFoundation 0x0000000112abcd4b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000011251e21e objc_exception_throw + 48
2 CoreFoundation 0x0000000112b2cf04 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x0000000112a42005 ___forwarding___ + 1013
4 CoreFoundation 0x0000000112a41b88 _CF_forwarding_prep_0 + 120
5 dates 0x000000010ef4e917 __35-[AWSIdentityManager completeLogin]_block_invoke_2 + 263
6 libdispatch.dylib 0x00000001150f4978 _dispatch_call_block_and_release + 12
7 libdispatch.dylib 0x000000011511e0cd _dispatch_client_callout + 8
8 libdispatch.dylib 0x00000001150fe8a4 _dispatch_main_queue_callback_4CF + 406
9 CoreFoundation 0x0000000112a80e49 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
10 CoreFoundation 0x0000000112a4637d __CFRunLoopRun + 2205
11 CoreFoundation 0x0000000112a45884 CFRunLoopRunSpecific + 420
12 GraphicsServices 0x0000000116249a6f GSEventRunModal + 161
13 UIKit 0x0000000112ee0c68 UIApplicationMain + 159
14 dates 0x000000010edac89f main + 111
15 libdyld.dylib 0x000000011516a68d start + 1
16 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
What have i tried? 我试过了什么?
What happens if I allow unauthenticated access?: the same, but a different response header :( 如果我允许未经身份验证的访问会发生什么?:相同,但不同的响应标头:(
2017-02-13 16:25:06.213 dates[25642:544704] AWSiOSSDK v2.5.0 [Debug] AWSURLSessionManager.m line:566 | -[AWSURLSessionManager printHTTPHeadersForResponse:] | Response headers:
{
Connection = "keep-alive";
"Content-Length" = 1612;
"Content-Type" = "application/x-amz-json-1.1";
Date = "Mon, 13 Feb 2017 15:25:05 GMT";
"x-amzn-RequestId" = "98feb58d-f200-11e6-9de9-471b5799b768";
}
2017-02-13 16:25:06.213 dates[25642:544704] AWSiOSSDK v2.5.0 [Debug] AWSURLResponseSerialization.m line:63 | -[AWSJSONResponseSerializer responseObjectForResponse:originalRequest:currentRequest:data:error:] | Response body:
{"Credentials":{"AccessKeyId":"ASIAISM6BUQFY6FJ4EFQ","Expiration":1.487003106E9,"SecretKey":"rlILMNjU7oeg1NEYgj1y3E1v/5L3IOJNWtZ7jsOf","SessionToken":"AgoGb3JpZ2luEFMaCWV1LXdlc3QtMSKAAgM0QlWyWW3xJ0H3+suiuuekGl6LUznBSikSWbYgLD9C6nPywAyKIlI5EVSN0q7o80q30ZWX8KE/Yjwo+axii1v/A2Qz9gqXWz4HRFwaJnHLE46nNLSJNNkNUhMkYy+azMCdKnZteUEtBzvHcWAVsyqAHtRSzKjGimXfs8WXs7d14g0GabTm73qj7tvOa4Facnetc9aUZjyLLKBsyOAnJKXwAN1xZja91qGbK2Tirfy2qu4kSDtJKcEPaSEnJTBqBlwdXS9D9JTOQNscNZEfpJpFNLdDmJ6ltbS/BwBN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":"eu-west-1:a9ef3c7f-8be8-411c-9249-48df6f04f4ac"}
2017-02-13 16:25:06.220 dates[25642:544675] -[AWSTask exception]: unrecognized selector sent to instance 0x6180002656c0
2017-02-13 16:25:06.222 dates[25642:544675] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AWSTask exception]: unrecognized selector sent to instance 0x6180002656c0'
*** First throw call stack:
(
0 CoreFoundation 0x000000010ff21d4b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010f98321e objc_exception_throw + 48
2 CoreFoundation 0x000000010ff91f04 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x000000010fea7005 ___forwarding___ + 1013
4 CoreFoundation 0x000000010fea6b88 _CF_forwarding_prep_0 + 120
5 dates 0x000000010c43d917 __35-[AWSIdentityManager completeLogin]_block_invoke_2 + 263
6 libdispatch.dylib 0x0000000112559978 _dispatch_call_block_and_release + 12
7 libdispatch.dylib 0x00000001125830cd _dispatch_client_callout + 8
8 libdispatch.dylib 0x00000001125638a4 _dispatch_main_queue_callback_4CF + 406
9 CoreFoundation 0x000000010fee5e49 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
10 CoreFoundation 0x000000010feab37d __CFRunLoopRun + 2205
11 CoreFoundation 0x000000010feaa884 CFRunLoopRunSpecific + 420
12 GraphicsServices 0x00000001136aea6f GSEventRunModal + 161
13 UIKit 0x0000000110345c68 UIApplicationMain + 159
14 dates 0x000000010c29b89f main + 111
15 libdyld.dylib 0x00000001125cf68d start + 1
16 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
The more i look at it it seems to be an issue with AWSTask. 我看的越多,它似乎是AWSTask的一个问题。
Any ideas where I might head next? 我可能会接下来的任何想法?
To get past this issue with AWSCognitoIdentityUserPoolConfiguration returning no access, am exploring turning on the un-authenticated access. 要通过AWSCognitoIdentityUserPoolConfiguration返回此问题而无法访问,我正在探索启用未经身份验证的访问权限。
When doing that, the App Delegate runs and gets unauthorized access. 执行此操作时,App Delegate会运行并获取未经授权的访问权限。 Then, in the user signup, will uses Sign In API in a Login ViewController to then get AWS credentials for authenticated access.
然后,在用户注册中,将在Login ViewController中使用Sign In API,然后获取AWS凭据以进行身份验证访问。
This allows us (if we want) to access DynamoDB, Lambda, while awaiting the user to logon the first time. 这允许我们(如果需要)访问DynamoDB,Lambda,同时等待用户第一次登录。 We can control what the app has to access by setting the correct policies for both authenticated and unauthenticated users.
我们可以通过为经过身份验证和未经身份验证的用户设置正确的策略来控制应用程序必须访问的内容。
This doc, although simple, has the best Swift example that I've found so far. 这个文档虽然很简单,却有迄今为止我发现的最好的Swift示例。
http://docs.aws.amazon.com/cognito/latest/developerguide/amazon-cognito-integrating-user-pools-with-identity-pools.html http://docs.aws.amazon.com/cognito/latest/developerguide/amazon-cognito-integrating-user-pools-with-identity-pools.html
Onto the next step! 进入下一步!
AWS通过Swift 3支持进行了更新,解决了该问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.