Closed mbahmani90 closed 4 months ago
@mbahmani90 I believe this ticket is meant for https://github.com/aws-amplify/aws-sdk-android. Can you confirm the AWS dependencies and IoT library being used so we can assign this properly.
Thank you for your response:
Depencenceis:
implementation 'com.amazonaws:aws-android-sdk-iot:2.75.2'
implementation 'com.amazonaws:aws-android-sdk-mobile-client:2.75.2'
implementation 'com.amplifyframework:core:2.16.0'
implementation 'com.amplifyframework:aws-api:2.16.0'
implementation 'com.amplifyframework:aws-datastore:2.16.0'
implementation 'com.amazonaws:aws-android-sdk-ddb:2.73.0'
implementation 'com.amazonaws:aws-android-sdk-mobile-client:2.75.2'
implementation 'com.amazonaws:aws-android-sdk-auth-core:2.75.2'
implementation 'com.amazonaws:aws-android-sdk-cognitoidentityprovider:2.75.2'
implementation 'com.amplifyframework:aws-auth-cognito:2.16.0'
implementation("io.github.jan-tennert.supabase:postgrest-kt:0.7.6")
implementation("io.ktor:ktor-client-cio:2.3.3")
implementation 'com.amplifyframework:aws-storage-s3:2.16.0'
implementation("aws.sdk.kotlin:dynamodb:1.0.30")
implementation("aws.sdk.kotlin:secretsmanager:1.0.30")
implementation("aws.smithy.kotlin:http-client-engine-okhttp:1.0.11")
implementation("aws.smithy.kotlin:http-client-engine-crt:0.30.0")
implementation 'aws.sdk.kotlin:aws-core:1.0.44'
@mbahmani90 Please see our compatibility statement and steps to use the AWS Android SDK IoT library with Amplify v2. https://docs.amplify.aws/gen1/android/sdk/configuration/amplify-compatibility/
You will need to remove com.amazonaws:aws-android-sdk-mobile-client
entirely from the project as this library conflicts with Amplify credentials and will cause continuous credential clearing. I see it listed multiple times in that list so please make sure it is removed entirely.
I removed com.amazonaws:aws-android-sdk-mobile-client
but again I received the same error.
According to https://github.com/aws-amplify/amplify-js/issues/1089
I activated the guest access: Cognito -> identity pool -> User Access -> Guest access -> Activate
then I open the guest role and I added this permission:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"iot:CreateThing",
"iot:DescribeThing",
"iot:DeleteThing",
"iot:AttachPolicy",
"iot:CreateKeysAndCertificate",
"cognito-identity:*",
"cognito-sync:*",
"sts:AssumeRole"
],
"Resource": "*"
}
]
}
And it works. Hopefully It would be secure enough!
Again thank you Tyler for your support!
Did you implement the Amplify Credentials Provider (https://docs.amplify.aws/gen1/android/sdk/configuration/amplify-compatibility/#creating-an-amplifycredentialsprovider), instead of the CognitoCachingCredentialsProvider?
Perfect!!!!
Now I understood what is AmplifyCredentialsProvider
.
It works. 👍
Great to hear!
Hi,
Hope you are all well.
I want to create thing via android kotlin.
Kotlin Code:
However, I receive error:
I also added different permissions to the IAM role like
AWSIoTFullAccess
,AWSIoTThingsRegistration
, and test custom policy:I have also check
Cognito -> user pool -> user access
and the role has been applied there. However, the error persists. Do you know how I should solve the error?Thank you.