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

getIdentityId() returns null the first time after Sign In in Android, crashes app but if reopened behaves normally #1510

Closed
abhidaa1233 opened this issue Feb 1, 2020 · 6 comments
Assignees
Labels
bug Something isn't working cognito Issues with the AWS Android SDK for Cognito

Comments

@abhidaa1233
Copy link

abhidaa1233 commented Feb 1, 2020

Describe the bug

getIdentityId() returns null the first time after signing in. This will
crashes the app. But when the app is reopened, things behave normally.

Here's the code that I have tried:

CognitoCachingCredentialsProvider credentialsProvider =
    new CognitoCachingCredentialsProvider(
        getApplicationContext(), // Context
        "IDENTITY_POOL_ID", // replaced by Identity Pool ID of mine 
        Regions.AP_SOUTH_1// Region
    );
new Thread(new Runnable() {
    @Override
    public void run() {
       String identityId = credentialsProvider.getIdentityId();
    }
}).start();

Had to start a new thread as it was giving error about using the main thread.
Another thing I tried:

new Thread(new Runnable() {
     @Override
     public void run() {
         final AWSCredentials credentials = AWSMobileClient.getInstance().getCredentials();
     }
}).start();
String identityId = AWSMobileClient.getInstance().getIdentityId();

Here's the error that shows up in Logcat:

Caused by: com.amazonaws.services.s3.model.AmazonS3Exception: Access Denied (Service: Amazon S3; Status Code: 403; Error Code: AccessDenied;

I get this same result every time.

Expected behavior
Normal, smooth login

Desktop (please complete the following information):

  • OS: [Android Oreo]

Thank you for your valuable time.


Update:

Actually, the issue is that the identity ID I am getting from these methods
calls the getIdentityId() 2 or 3 times within few seconds. If it is called 3
times, then one time it mostly comes null. One is right, and one is wrong.
This crashes the app, but when restarted it behaves normal. I somehow took the
ID in a final String and it's currently works but please solve the bug.

Thank you.

@abhidaa1233
Copy link
Author

Any updates regarding this issue?

@desokroshan desokroshan transferred this issue from aws-amplify/docs Mar 9, 2020
@desokroshan desokroshan added cognito Issues with the AWS Android SDK for Cognito question General question and removed cognito Issues with the AWS Android SDK for Cognito labels Mar 9, 2020
@TrekSoft TrekSoft added bug Something isn't working and removed question General question labels Mar 20, 2020
@aws-amplify aws-amplify deleted a comment from Diegolotr99 Nov 15, 2020
@aws-amplify aws-amplify deleted a comment from raphkim Nov 15, 2020
@aws-amplify aws-amplify deleted a comment from Diegolotr99 Nov 15, 2020
@aws-amplify aws-amplify deleted a comment from Diegolotr99 Nov 15, 2020
@Diegolotr99
Copy link

Why aws-amplify DELETING COMMENTS ??

@jamesonwilliams
Copy link
Contributor

jamesonwilliams commented Nov 24, 2020

Hi, @Diegolotr99. I condensed some information back into the original post, that's all. Cheers.

@Diegolotr99
Copy link

Hi @jamesonwilliams , Cheers. Still looking for any help here -> aws-amplify/amplify-android#962

@jamesonwilliams
Copy link
Contributor

jamesonwilliams commented Nov 24, 2020

@Diegolotr99 Please do not spam unrelated issues, to advertise your other issues. That creates noise for folks who are trying to follow this ticket. If you have additional relevant details to provide to either GitHub issue, please do so.

Feel free to join our Discord server if you need additional help. https://discord.gg/amplify

@gpanshu
Copy link
Contributor

gpanshu commented Mar 18, 2022

HI @abhidaa1233 please advise if this is still an issue as this github issue is quite old. Please try with the latest libraries. If this is still happening we will do a deep dive and fix it.

@gpanshu gpanshu self-assigned this Mar 18, 2022
@gpanshu gpanshu closed this as completed Mar 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cognito Issues with the AWS Android SDK for Cognito
Projects
None yet
Development

No branches or pull requests

6 participants