gpt4 book ai didi

ios - AWS 认知 : "Unauthenticated access is not supported for this identity pool."

转载 作者:可可西里 更新时间:2023-10-31 23:48:30 40 4
gpt4 key购买 nike

我正在解决一个问题 “此身份池不支持未经身份验证的访问。” 来 self 的 Swift iOS 应用程序中的 AWS Cognito。我以前使用 Firebase 进行身份验证和存储,并出于超出此问题范围的原因决定迁移到 AWS Mobile Hud。

我使用/已经设置:

  1. Amazon Mobile Hud 提供所有服务
  2. 通过 Mobile Hud 进行身份验证/身份验证的 AWS Cognito
  3. 激活 Facebook 作为身份提供者
  4. AWS DynamoDB 在控制台中激活但尚未使用
  5. AWS S3 在控制台中激活但尚未使用

我下载了为我的项目生成的示例应用程序并运行它。

Through the sample app, I am able to successfully register / authenticate through Facebook and Cognito.

有什么用?:我已经将 AWS 的所有 SDK/Frameworks 集成到我的项目中并且能够成功构建(注意:所有 AWS 框架都通过 cocoapods 集成,除了“AWSMobileHubHelper”作为静态框架)。

I can build the app and it opens

什么不起作用?应用程序在打开后立即崩溃,并显示以下崩溃日志:

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

我尝试了什么?

  1. 将我的代码与示例应用程序进行了比较:结果 - 据我所知是 1:1 匹配
  2. 将 Info.plist 与示例应用进行比较:结果 - 1:1 匹配(我复制了相关部分)
  3. 删除所有框架,清理,重建
  4. 清理所有模拟器数据(被另一个类似的问题引用)
  5. 相关问题的尝试方法:(检查未经身份验证的访问)

如果我允许未经身份验证的访问会怎样?相同,但响应 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+azMCdKnZteUEtBzvHcWAVsyqAHtRSzKjGimXfs8WXs7d14g0GabTm73qj7tvOa4Facnetc9aUZjyLLKBsyOAnJKXwAN1xZja91qGbK2Tirfy2qu4kSDtJK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FvaL/jXIGIDaUT9os0WR0mWybmCCd9Gwo25zsw0p+HxQU="},"IdentityId":"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

我看得越多,似乎是 AWSTask 的问题。

我接下来可能去哪里有什么想法吗?

最佳答案

为了解决 AWSCognitoIdentityUserPoolConfiguration 不返回访问权限的问题,我正在探索打开未经身份验证的访问权限。

这样做时,App Delegate 会运行并获得未经授权的访问。然后,在用户注册中,将在登录 ViewController 中使用登录 API,然后获取 AWS 凭证以进行身份​​验证访问。

这允许我们(如果我们想要)访问 DynamoDB、Lambda,同时等待用户首次登录。我们可以通过为经过身份验证的用户和未经身份验证的用户设置正确的策略来控制应用必须访问的内容。

该文档虽然简单,但却包含迄今为止我找到的最好的 Swift 示例。

http://docs.aws.amazon.com/cognito/latest/developerguide/amazon-cognito-integrating-user-pools-with-identity-pools.html

进入下一步!

关于ios - AWS 认知 : "Unauthenticated access is not supported for this identity pool.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42207640/

40 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com