使用IAM从Android MQTT客户端登录AWS IoT无法正常工作 [英] AWS IoT login from android MQTT client using IAM is not working

查看:245
本文介绍了使用IAM从Android MQTT客户端登录AWS IoT无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直试图将我的android应用程序连接到AWS IoT门户.我已经创建了一个IAM帐户,该帐户具有用户名和密码.我已经阅读了文档,但看不到任何适当的指南.我读到某处可以通过IAM/Cognito/使用证书访问IoT设备的地方.由于我是Android用户,因此我不能(我不想)使用设备证书.我可以使用IAM凭证访问我的AWS IoT设备吗?我已经下载了所有示例应用程序,但是找不到任何工作代码.或者有人可以解释我如何从Android应用程序访问AWS IoT门户?

I have been trying to connect my android application to AWS IoT portal. I have created an IAM account, which has a username and password. I have gone through the documentation but I could not see any proper guideline. I read somewhere that I can access the IoT devices through IAM/Cognito/using a certificate. Since I am an Android user I can't(I don't want to) use a device certificate. Can I use my IAM credentials to access my AWS IoT devices? I have downloaded all sample application and I could not find any working code. Or could someone explain how can I access AWS IoT portal from android app?

推荐答案

看到您的评论和问题.使用AndroidPubSubWebSocket时遇到类似的问题.确保您已按照AWS的Github回购指令中的说明授予适当的权限来发布和订阅该内容.假设已经完成.

Seeing your comments and questions. I had the similar issues when working with AndroidPubSubWebSocket. Make sure you are giving appropriate permission to publish and subscribe to the thing as given in the Github repo instruction by AWS. Assuming that has been done.

  1. Github AndroidPubSuB中提供的示例仅适用于未经身份验证的用户.对于经过身份验证的用户(此处为Facebook),AWS端和Android端都无需添加任何内容

Android

Map<String, String> logins = new HashMap<String, String>();
        logins.put("graph.facebook.com", AccessToken.getCurrentAccessToken().getToken());
        credentialsProvider.setLogins(logins);

上面的代码是必需的,因为AwsCredentialProvider使用它来对用户进行身份验证以发布和连接到事物.

The above code is necessary as it is used by AwsCredentialProvider for authentication of the user for publishing and connecting to the thing.

完成以上操作后

After you are done with above head here. Follow the answer by Caleb and do the exact steps.

在这之后,你很好.

  1. 未经身份验证的用户为AWS中的用户和区域创建一个池.得到东西的终点.进行适当的更改.
  1. For Unauthenticated user create a pool for users and region in AWS. Get the thing end point. Make the appropriate changes.

要获得对阴影的更改,请在示例android(WebSocketAwsOubSub)编辑框中键入以下内容$aws/things/thing_name/shadow/update/accepted

To get the changes to the shadow type the following in the sample android(WebSocketAwsOubSub) edit box $aws/things/thing_name/shadow/update/accepted

并将数据发布到影子类型$aws/things/thing_name/shadow/update

And to publish the data to the shadow type $aws/things/thing_name/shadow/update

这篇关于使用IAM从Android MQTT客户端登录AWS IoT无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆