问题标签 [aws-sdk-ios]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
ios - API Gateway generated SDK for iOS (Objective-C) with Cognito User Pool for authorized users
I have deployed an API using AWS API Gateway and I am trying to access it through an iOS device. Some endpoints support unauthorized users and I have no trouble accessing them but others don't and I can't manage to query them. I use the new Cognito User Pool feature for authentication which works fine when using a web application (or postman).
First, even though some of the endpoints are protected (like in the following picture of the console), when I deploy the API and generate the SDK for iOS (Objective-C), I can read in the README file: "All endpoints do not require authorization."
Then, when I run the following authentication code from AWS documentation, everything seems to work just fine:
I implemented CognitoPoolIdentityProvider as specified in this post.
I manage to get a proper token (tested using postman) and a user id:
2016-12-27 12:43:35.760 AskHub[26625:10037234] AWSiOSSDK v2.4.11 [Debug] AWSURLResponseSerialization.m line:63 | -[AWSJSONResponseSerializer responseObjectForResponse:originalRequest:currentRequest:data:error:] | Response body: {"IdentityId":"eu-west-1:XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"} 2016-12-27 12:43:35.766 AskHub[26625:10037234] Identity id: eu-west-1:XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
However, when I run the following code to hit a protected endpoint, CloudFront considers that I am not authenticated.
Reponse:
2016-12-27 12:56:25.247 AskHub[26784:10046562] Could not send initial request: Error Domain=com.amazonaws.AWSAPIGatewayErrorDomain Code=1 "(null)" UserInfo={HTTPBody={ message = Unauthorized; }, HTTPHeaderFields={type = immutable dict, count = 9, entries => 3 : Via = {contents = "X.X XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.cloudfront.net (CloudFront)"} 4 : x-amzn-ErrorType = {contents = "UnauthorizedException"} 5 : Content-Type = {contents = "application/json"} 6 : Content-Length = {contents = "27"} 7 : Connection = {contents = "keep-alive"} 8 : x-amzn-RequestId = {contents = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"} 9 : Date = {contents = "Tue, 27 Dec 2016 11:56:25 GMT"} 10 : X-Cache = {contents = "Error from cloudfront"} 11 : X-Amz-Cf-Id = {contents = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"} } }
Am I missing something here? Does the automatically generated SDK support User Pool authentication?
ios - 使用 Amazon Cognito 开发人员身份
我正在关注亚马逊文档,但它不像宣传的那样工作。我也有最新的sdk。下面的 self.identity = 代码不起作用,因为它是只读的。
我如何克服这个?谢谢。
ios - 以开发人员身份使用 AWS Cognito 和 aws-ios-sdk v.2.4.16
我设置了一组 lambda 函数来完成我的所有身份验证。我通过 api 网关从我的应用程序连接,然后最后调用 GetOpenIdTokenForDeveloperIdentity()。这会通过网关向我的设备返回一个 identityId 和令牌。
接下来我按照本网站的说明(针对 Objective-C): http ://docs.aws.amazon.com/cognito/latest/developerguide/developer-authenticated-identities.html
因为我有 identityId 和 token,所以我从这个开始:
开发者提供者.h
开发者提供者.m
我从上面得到两个错误:
- 在 .h 文件中,我得到“找不到 AWSCognitoCredentialsProviderHelper 的接口”
- 在 .m 文件中,我得到“identityId 是对只读属性 self.identityId 的分配”
我已经重新安装了 CocoaPods 并重新安装了 aws-ios-sdk。我什至清理了所有旧文件和派生数据。
我错过了什么吗?最终目标是能够让经过身份验证的用户能够直接从应用程序调用 dynamodb 和 s3,而无需再使用网关和 lambda,因为用户已通过身份验证。谢谢。
ios - AWS Cognito iOS。注销后出现未经验证的错误
我正在使用 AWS Cognito,通过 MobileHub 与 iOS 应用程序集成以通过 Facebook 登录。一切正常,直到我注销现有身份并尝试使用另一个 FB 帐户(甚至相同)登录。
在这种情况下,每次调用任何 AWS Lambda 时都会出现此错误:
AWSiOSSDK v2.4.9 [错误] AWSCredentialsProvider.m 行:577。
[AWSCognitoCredentialsProvider 凭证]。
无法刷新。错误是 [Error Domain=com.amazonaws.AWSCognitoIdentityErrorDomain Code=8 "(null)" UserInfo={__type=NotAuthorizedException, message=此身份池不支持未经身份验证的访问。}]
但是,如果我终止并重新启动应用程序,一切都会再次正常运行。
此错误源自此处:
通过阅读 AWS SDK 代码,我看到这是因为 cognito 身份没有从这里的凭证提供者那里获得登录信息:
我想这是意料之中的,因为我已经注销了。但问题是即使在登录 FB AWS 后仍然认为我未经授权。从 StackOverflow 上的类似问题我看到,过去人们在 AWSCognitoCredentialsProvider 上手动设置登录字典。但现在这个属性已被弃用,其他类似的属性是只读的。
这是我在 AppDelegate didFinishLaunchingWithOptions 方法中的 AWS 设置:
这是注销代码:
请注意,我尝试了清除钥匙串并没有这样做。结果是一样的。
我真的很感激任何帮助!
最好的问候,亚历克斯
ios - 导致文档错误我得到 CognitoIdentityCredentials 未被授权执行:dynamodb:UpdateItem on resource
我发现文件错了,因为错了总是不能运行成功,当然我也有错,我没有看清楚,如果你现在受苦,请检查如下:
dynamoDBTableName -> 字符串
在错误的文档中,错误如下:
在“Amazon DynamoDB:存储和检索应用程序数据”中
在“创建 DynamoDB 表和索引”
它说
3.输入“Books”作为表名
但是在示例代码中写如下:
不是返回“Book”,应该返回“Books”,难怪,哈哈,我总是得到错误“CognitoIdentityCredentials is not authorized to perform: dynamodb: UpdateItem on resource”
如果您也总是出错,请检查您的表名返回是否相同,祝您有美好的一天。
ios - 使用数组查询 AWS Dynamo Db 数据库
我正在尝试使用 AWS Dynamo Db 构建应用程序,我想查询或扫描我的数据库,但是我只能使用一个参数来扫描数据库,但我无法使用数组查询数据库。
例如,我的user details
数据库中有一个带有主键的表UserID
。我想获得几行并将它们UserID
存储在一个数组中。
这是我尝试使用的代码,但对我不起作用。有人可以帮我吗?谢谢。
ios - AmazonClientManager - AWSCognito GPlus 登录 iOS 中的 resumeSessionWithCompletionHandler 问题
大家好,在 iOS 中用于 GPlus AWSCognito 登录的 AmazonClientManager 中的 resumeSessionWithCompletionHandler 遇到了一些问题。但同样的恢复会话适用于 Facebook 登录。你能帮我解决这个问题吗?这是我在iOS中使用的代码,
如果您有解决此问题的想法,这将对我有所帮助。
objective-c - AWS Cognito 与 AWSCognitoDataset iOS 同步问题
在 iOS 的 AWSCognitoDataset 中同步 Facebook 和 GPlus 登录凭证时出现以下错误,
任务响应是 :: AWSTask: 0x16018ce0; 完成=是;取消=否;故障=是;结果=(空)
任务错误是 :: Error Domain=com.amazon.cognito.AWSCognitoErrorDomain Code=-4000 "(null)"
我的代码是,
如aws doc中所述,我正确清除了所有钥匙串和其他东西。如果有人对此有任何想法,那将会很有帮助。适用于 iOS 的 AWS Cognito 同步有什么问题吗?
ios - 在ios中为我们自己的mqtt服务器使用aws ios iot sdk
我们使用带有 ssl 配置的 AWS iOS IoT SDK。我们遵循https://github.com/awslabs/aws-sdk-ios-samples/tree/master/IoT-Sample/Swift作为参考。这里我们的服务器端点将是格式
https://xxxxxxxxxx.iot ..amazonaws.com
我们以捆绑包的形式导入 pkcs12 文件,并能够连接、发布、订阅服务器。
后来我们考虑在我们的组织内有本地网络解决方案,我们为服务器的 MQTT 代理设置了 rabbitmq https://www.rabbitmq.com/ssl.html#keys-and-certs。目前,我们正在尝试使用 ec2 实例,后者将设置本地服务器。终点是
ssl://ec2-..compute.amazonaws.com:8883
现在我无法使用 aws iot ios sdk 连接到 rabbitmq 服务器。
但是如果我使用https://github.com/emqtt/CocoaMQTT示例,我可以同时连接到 aws iot 服务器端点和 rabbitmq 服务器端点。
我现在应该怎么做才能使用 aws iot ios sdk https://github.com/aws/aws-sdk-ios/tree/master/AWSIoT连接到 rabbitmq 服务器端点。我应该在 sdk 中进行哪些编辑?
以下是尝试使用 aws iot ios sdk 连接到 rabbitmq 服务器时的日志。
ios - AWS Cognito 在 Swift 中获取用户组
因此,我在 Swift 中的 iOS 应用程序上实现了 Amazon Cognito 登录,一切都很好。但是,我现在正试图找出登录用户所属的组。我似乎无法从应用程序中找到执行此操作的好方法。从我所见,SDK 似乎没有提供这样做的方法。任何帮助将非常感激!