Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndentityId get refreshed after one hour, provoking 401 code response #2751

Closed
1 task done
yktoledo opened this issue Apr 2, 2024 · 4 comments
Closed
1 task done
Labels
auth Related to the Auth category/plugins bug Something isn't working

Comments

@yktoledo
Copy link

yktoledo commented Apr 2, 2024

Before opening, please confirm:

Language and Async Model

Kotlin - Coroutines

Amplify Categories

Authentication, REST API

Gradle script dependencies

// Put output below this line
    implementation 'com.amplifyframework:core:2.14.11'
    implementation 'com.amplifyframework:aws-api:2.14.11'
    implementation 'com.amplifyframework:aws-auth-cognito:2.14.11'

Environment information

# Put output below this line

------------------------------------------------------------
Gradle 8.2
------------------------------------------------------------

Kotlin:       1.8.20
Groovy:       3.0.17
Ant:          Apache Ant(TM) version 1.10.13 compiled on January 4 2023
JVM:          17.0.7 (JetBrains s.r.o. 17.0.7+7-b985.2)
OS:           Mac OS X 14.4.1 aarch64


Please include any relevant guides or documentation you're referencing

https://docs.amplify.aws/android/build-a-backend/auth/enable-guest-access/

Describe the bug

I want to consume API Gateway resource using authorizationType:AWS_IAM and "Enable guest access" (Allow unauthenticated logins), based on the documentation, "you can obtain the unique Identity ID which is assigned to the device through the fetchAuthSession method", with the intention to use this "identity id" as the device identifier to communicate, after a little a bit more than one hour of fresh install, the credentials get refreshed, which is perfect, but the identityId too, I will assume is not the expected behavior.

Maybe I'm missing something, server configuration specific or android implementation detail, despite is so minimal the amount of code use, 4 line of code, add plugins call with api and auth, follow by the configure call, after that just the get call.

Following the doc https://docs.amplify.aws/android/build-a-backend/restapi/fetch-data/

// add this to log
Amplify.addPlugin(AndroidLoggingPlugin(LogLevel.VERBOSE))

Amplify.addPlugin(AWSApiPlugin())
Amplify.addPlugin(AWSCognitoAuthPlugin())
Amplify.configure(applicationContext)

val response = Amplify.API.get(request)

I appreciate it if you can help me on this.

Note: following the same steps in iOS is not having the same problem, iOS keeps the identity id all the time.

Reproduction steps (if applicable)

No response

Code Snippet

// Put your code below this line.

Log output

// Put your logs below this line


amplifyconfiguration.json

{
    "auth": {
        "plugins": {
            "awsCognitoAuthPlugin": {
                "IdentityManager": {
                    "Default": {}
                },
                "CredentialsProvider": {
                    "CognitoIdentity": {
                        "Default": {
                            "PoolId": "[COGNITO IDENTITY POOL ID]",
                            "Region": "[REGION]"
                        }
                    }
                },
                "CognitoUserPool": {
                    "Default": {
                        "PoolId": "[COGNITO USER POOL ID]",
                        "AppClientId": "[COGNITO USER POOL APP CLIENT ID]",
                        "Region": "[REGION]"
                    }
                },
                "Auth": {
                    "Default": {
                        "authenticationFlowType": "USER_SRP_AUTH",
                        "OAuth": {
                            "WebDomain": "[YOUR COGNITO DOMAIN ]",
                            "AppClientId": "[COGNITO USER POOL APP CLIENT ID]",
                            "SignInRedirectURI": "[CUSTOM REDIRECT SCHEME AFTER SIGN IN, e.g. myapp://]",
                            "SignOutRedirectURI": "[CUSTOM REDIRECT SCHEME AFTER SIGN OUT, e.g. myapp://]",
                            "Scopes": [ 
                                "phone",
                                "email",
                                "openid",
                                "profile",
                                "aws.cognito.signin.user.admin"
                            ]
                        }
                    }
                }
            }
        }
    },
"api": {
        "plugins": {
            "awsAPIPlugin": {
                "[API NAME]": {
                    "endpointType": "REST",
                    "endpoint": "[API GATEWAY ENDPOINT]",
                    "region": "[REGION]",
                    "authorizationType": "AWS_IAM",
                    ...
                }
            }
        }
    }
}

GraphQL Schema

// Put your schema below this line

Additional information and screenshots

No response

@github-actions github-actions bot added the pending-triage Issue is pending triage label Apr 2, 2024
@joon-won
Copy link
Member

joon-won commented Apr 2, 2024

@yktoledo Thanks for the report, we will take a look into this issue

@joon-won joon-won added auth Related to the Auth category/plugins and removed pending-triage Issue is pending triage labels Apr 2, 2024
@sktimalsina sktimalsina added the pending-triage Issue is pending triage label Apr 2, 2024
@joon-won joon-won added the bug Something isn't working label Apr 2, 2024
@github-actions github-actions bot removed the pending-triage Issue is pending triage label Apr 2, 2024
@joon-won
Copy link
Member

Hey @yktoledo, thank you for your patience. This issue will be addressed with the next release version. Please let us know if there's any further concern.

@mattcreaser mattcreaser added the pending-release Code has been merged but pending release label Apr 11, 2024
@joon-won joon-won added closing soon This issue will be closed in 7 days unless further comments are made. and removed pending-release Code has been merged but pending release labels Apr 15, 2024
@joon-won
Copy link
Member

Closing this issue as the issue has been addressed with our latest release 2.15.1. Please re-open the issue if you have further question or issue!

@github-actions github-actions bot removed the closing soon This issue will be closed in 7 days unless further comments are made. label Apr 19, 2024
Copy link
Contributor

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auth Related to the Auth category/plugins bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants