Exchanging AWS Cognito token to get AWS temporary credentials for publishing to AWS IoT Core MQTT topic #2533
-
Hi, I'm able to login using my Cognito user credentials and get access token successfully. How do I use the credentials object returned from SRP auth flow to create AWS IoT client object? I'm thinking there has to be a way to get temporary access key ID, secret access key and access token using the token that I get from Cognito, right? On a different path, I've been able to use my access key ID, secret access key and access token that I generated for an admin user in my account to successfully publish to AWS IoT core topics. However, I'm looking to achieve the same using credentials obtained from my Cognito user pool. Please note that the Auth role for Cognito has access to iot:* for all resources in my account already. Here's the code that works fine (using my admin access credentials):
And here's the code that I'm trying to make work (using Cognito user credentials):
All I get is an error message: |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
@Vijay-Karthick Have you tried referencing IAM roles and Role-based access control? Does the role that authenticated users assume have sufficient permissions? Thanks, |
Beta Was this translation helpful? Give feedback.
-
Hi Ashish, I figured out the root cause. For IoT specifically, Cognito identities will need to be given permissions (RBAC) via IoT Policies.
Kind regards, |
Beta Was this translation helpful? Give feedback.
-
You can close this case. |
Beta Was this translation helpful? Give feedback.
Hi Ashish,
I figured out the root cause. For IoT specifically, Cognito identities will need to be given permissions (RBAC) via IoT Policies.
Solution:
aws iot attach-principal-policy --principal --policy-name "" --region
Kind regards,
Vijay