Skip to content
This repository has been archived by the owner on Apr 2, 2018. It is now read-only.

CredentialsError: Missing credentials in config #33

Open
mediastormcreative opened this issue Jul 20, 2017 · 9 comments
Open

CredentialsError: Missing credentials in config #33

mediastormcreative opened this issue Jul 20, 2017 · 9 comments

Comments

@mediastormcreative
Copy link

Hi, when running the aws-starter-kit I get this error message, 'CredentialsError: Missing credentials in config' when trying to view or add a Task. The full error message is as follows,

CredentialsError: Missing credentials in config
Stack trace:
handleRequest/<@http://localhost:8100/assets/aws-sdk.min.js:40:14371
f</t.prototype.invokeTask@http://localhost:8100/build/polyfills.js:3:9956
onInvokeTask@http://localhost:8100/build/vendor.js:4499:28
f</t.prototype.invokeTask@http://localhost:8100/build/polyfills.js:3:9869
c</r.prototype.runTask@http://localhost:8100/build/polyfills.js:3:5124
t/this.invoke@http://localhost:8100/build/polyfills.js:3:10938

I did not modify the code apart from downloading the aws-config.js file. The auth process seems to work fine in that I can create a user profile and then log in. The Task window remains blank, however. I get the same error message when trying to add a task. I appreciate any help you can give me on this!

@mlynch
Copy link
Contributor

mlynch commented Jul 28, 2017

Looking into this, the format may have changed

@mlynch
Copy link
Contributor

mlynch commented Jul 28, 2017

Hmm, not able to reproduce. Does it work if you refresh and then try?

@fmendoza
Copy link

fmendoza commented Aug 3, 2017

I have the same issue but it happens random.

@alberthotel
Copy link

Is this issue resolved? I think I have run into similar issue with the same error. On debugging, I found that:

Whenever the first time I logged out of a user and then login again using another user, the identityId of the AWS.config.credentials.identityId remains that of the previous user, so that when I call AWS Dynamodb:

this.db.getDocumentClient().query({
  'TableName': this.taskTable,
  'KeyConditionExpression': "#userId = :userId",
  'ExpressionAttributeNames': {
    '#userId': 'userId'
  },
  'ExpressionAttributeValues': {
    ':userId': AWS.config.credentials.identityId
  },
  'ScanIndexForward': false
}).promise().then((data) => {

it will have this error:
Error: Missing credentials in config

I can't find a way to refresh/reset the credentials to have the identity ID of the newly successful login...

However, when I refresh the page for that same (second logged-in user), on the second time, the identityId is set correctly so that the Dynamodb query string returns correctly.

Anyone has any idea why this is happening?

@fmendoza
Copy link

I fixed this issue calling AWS.config.credentials.clearCachedId() in the logout method (user.ts)

Before:

logout() {
    this.user = null;
    this.cognito.getUserPool().getCurrentUser().signOut();
  }

After:

logout() {
    this.user = null;
    this.cognito.getUserPool().getCurrentUser().signOut();
    AWS.config.credentials.clearCachedId();
  }

Reference: https://stackoverflow.com/questions/29524973/how-to-logout-from-amazon-cognito-javascript-and-clear-cached-identityid

@alberthotel
Copy link

Thanks, Fmendoza! Your suggestion works perfectly and solve my issue! The ionic2-starter-aws team should add this line to the default code so others will not encounter the same issue.

@davidquon
Copy link

I have the original issue when selecting Settings->Account->Change Photo and take a new photo and accept it in the camera for the user account. I then get the following error.

upload failed....
Error: Missing credentials in config
__zone_symbol__currentTask:null
code:"CredentialsError"
hostname:"cognito-identity.us-west-1.amazonaws.com"
message:"Missing credentials in config"
name:"NetworkingError"
originalError:Object {message: "Could not load credentials from constructor", code: "CredentialsError", time: Fri Sep 08 2017 17:09:59 GMT-0700 (PDT), …}
region:"us-west-1"
retryable:true
stack:"NetworkingError: Missing credentials in config\n    at XMLHttpRequest.<anonymous> (file:///android_asset/www/assets/aws-sdk.min.js:37:6645)\n    at t.invokeTask (file:///android_asset/www/build/polyfills.js:3:9967)\n    at Object.onInvokeTask (file:///android_asset/www/build/vendor.js:4499:37)\n    at t.invokeTask (file:///android_asset/www/build/polyfills.js:3:9888)\n    at r.runTask (file:///android_asset/www/build/polyfills.js:3:5143)\n    at XMLHttpRequest.invoke (file:///android_asset/www/build/polyfills.js:3:10945)"
time:Fri Sep 08 2017 17:09:59 GMT-0700 (PDT) {}
__proto__:Object {name: "Error", message: "", constructor: , …}

This was referenced Sep 9, 2017
@davidquon
Copy link

So it turns out the problem I was experiencing above was due to changing the region to US West (California) in the AWS Mobile Hub. Changing the region pointed me to cognito-identity.us-west-1.amazonaws.com which does not exist which caused obvious havoc when trying to authenticate to use AWS services. If I started over and used the default region US East (Virginia) then everything works as expected. 😥

@davidquon
Copy link

After unzipping mobile-hub-project.zip and inspecting the mobile-hub-project.yml I wonder if the region will be 💯 tied to US East due to this line.

region: us-east-1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants