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

Error: No credentials, applicationId or region #5918

Closed
nihp opened this issue May 27, 2020 · 45 comments
Closed

Error: No credentials, applicationId or region #5918

nihp opened this issue May 27, 2020 · 45 comments
Assignees
Labels
Analytics Related to analytics React Native React Native related issue

Comments

@nihp
Copy link

nihp commented May 27, 2020

Error: No credentials, applicationId or region with the latest aws-amplify ad aws-amplify-react-native version.

    "aws-amplify": "^3.0.11",
    "aws-amplify-react-native": "^4.1.2",
    "aws-sdk": "^2.681.0",

Auth.signIn succeeds but throws console error and every time it showing the warning

#5629 fix not working in the latest version.

@ashika01 Can you let me know if you have any updates or whether I need to change anything from my side

@nihp nihp added the to-be-reproduced Used in order for Amplify to reproduce said issue label May 27, 2020
@mauerbac mauerbac assigned ashika01 and unassigned ashika01 May 27, 2020
@ashika01
Copy link
Contributor

@nihp My fix was for just this issue which is the error coming from AWSPinpointProvider.js. Looking at the screenshot of error log on the PR referenced above. It unclear to me where this is coming from.

We will have someone from the team to look at this. In any case, sample code to reproduce the issue will help the team resolve your issue faster. Could you provide us with sample code and how your aws-exports (removing sensitive info) look like.?

@ashika01 ashika01 added React Native React Native related issue pending-close-response-required A response is required for this issue to remain open, it will be closed within the next 7 days. labels May 27, 2020
@sammartinez
Copy link
Contributor

@nihp,

I do want to callout that we do have others on the team that review besides @ashika01. While it's alright to tag people in order to look at issues, it's not recommended as people can be on vacation at times or out of the office. We do take in issues as a first come and first serve approach as well so it may take some time for us to get back to you on issues. As stated above, we can have someone look into this but can you provide us a sample code of what you're experiencing in order to help you further? Thanks ahead of time.

@stale stale bot removed the pending-close-response-required A response is required for this issue to remain open, it will be closed within the next 7 days. label May 27, 2020
@sammartinez sammartinez added the pending-close-response-required A response is required for this issue to remain open, it will be closed within the next 7 days. label May 27, 2020
@nihp
Copy link
Author

nihp commented May 28, 2020

For me it happening before as well as after upgrading the latest version too.

//aws-exports.js

const awsmobile = {
    "aws_project_region": "xxxxx",
    "aws_cognito_identity_pool_id": "xxxxxx",
    "aws_cognito_region": "xxxxxx",
    "aws_user_pools_id": "xxxxxx",
    "aws_user_pools_web_client_id": "xxxxxx",
    "oauth": {},
    "aws_user_files_s3_bucket": "xxxxxx",
    "aws_user_files_s3_bucket_region": "xxxxxx"
}

export default awsmobile;

@stale stale bot removed the pending-close-response-required A response is required for this issue to remain open, it will be closed within the next 7 days. label May 28, 2020
@sammartinez
Copy link
Contributor

@nihp Are you installing the aws-sdk package as well as the aws-amplify package? We do have a dependency on aws-sdk that we install for you. Please let us know

@nihp
Copy link
Author

nihp commented May 29, 2020

In the latest update of aws-amplify, they removed aws-sdk dependency and we need to install separately according to this doc.

So here I have used aws-amplify, aws-amplify-react-native and aws-sdk v2.

Update of amplify 3..x.x:

Amplify@3.x.x has breaking changes. Please see the breaking changes below:

AWS.credentials and AWS.config don’t exist anymore anywhere in Amplify JS
Both options will not be available to use in version 3. You will not be able to use and set your own credentials.
Migration plan on “How to migrate to using Amplify provided credentials” will follow in the coming weeks after GA launch.

aws-sdk@2.x has been removed from Amplify@3.x.x in favor of version 3 of aws-sdk-js. We recommend to migrate to aws-sdk-js-v3 if you rely on AWS services that are not supported by, Amplify, since aws-sdk-js-v3 is imported modularly.
If you can't migrate to aws-sdk-js-v3 or rely on aws-sdk@2.x, you will need to import it separately.

We do have a dependency on aws-sdk that we install for you.

If you have any updates let me know

@joostfarla
Copy link
Contributor

I had the same issue (running on the latest Amplify v3) and worked around it by changing the following:

Amplify.configure({
  ...config,
  Analytics: {
    disabled: true,
  },
});

The strange thing is that I'm not using Analytics at all, but apparently the error is gone.

@macrouch
Copy link

macrouch commented Jun 1, 2020

I had the same issue (running on the latest Amplify v3) and worked around it by changing the following:

Amplify.configure({
  ...config,
  Analytics: {
    disabled: true,
  },
});

The strange thing is that I'm not using Analytics at all, but apparently the error is gone.

This fixed my error, thanks!

@nihp
Copy link
Author

nihp commented Jun 1, 2020

I had the same issue (running on the latest Amplify v3) and worked around it by changing the following:

Amplify.configure({
  ...config,
  Analytics: {
    disabled: true,
  },
});

The strange thing is that I'm not using Analytics at all, but apparently the error is gone.

@joostfarla Your solution worked for me. Thanks

@nihp nihp closed this as completed Jun 1, 2020
@nihp
Copy link
Author

nihp commented Jun 4, 2020

Can anyone explain what is the root cause of the error? And after adding the Analytics: false it worked.

@witalobenicio
Copy link

And what to do if you use Analytics?? (which is my case)

@ashika01
Copy link
Contributor

ashika01 commented Jul 1, 2020

@witalobenicio Ideally you shouldn't see the error if use analytics.. If you do see it then, then there is something you are missing while configuring Analytics

@nihp
Copy link
Author

nihp commented Jul 2, 2020

Again I am facing the same error.

After adding analytics true it worked and after two days we again faced the same error. Now I didn't have any solution for this. Still facing the same issue.

@nihp nihp reopened this Jul 2, 2020
@witalobenicio
Copy link

witalobenicio commented Jul 3, 2020

@ashika01 This error happens if I use @aws-amplify/analytics and @aws-amplify/core. When I use just import Amplify from 'aws-amplify'; it works.

The problem is that this package is a waaaay huge to just use it for analytics.

Can we have a solution?

@rubene
Copy link

rubene commented Jul 28, 2020

We are facing the same issue, but it does not happen consistently. After inspecting our error tracking tool the call to get the credentials on

return Amplify.Auth.currentUserCredentials();
seems to be getting a 400 response from Cognito

@sammartinez sammartinez added the Analytics Related to analytics label Sep 16, 2020
@outspokeio
Copy link

outspokeio commented Sep 21, 2020

I had the same problem and was stuck - nothing above worked... until I actually uninstalled the @aws-amplify/analytics and @aws-amplify/auth packages. Even though I wasn't importing either of them their presence was enough to cause the error, it seems.

@sammartinez sammartinez added not-reproducible Not able to reproduce the issue and removed to-be-reproduced Used in order for Amplify to reproduce said issue labels Sep 24, 2020
@ashika01 ashika01 removed their assignment Oct 9, 2020
@mateomorrison
Copy link

If you still have this problem (I did with aws-amplify@latest), I added the code to my solutions repo. Also rm -rf node_modules and then npm i or yarn. This should clear it.

@DavidWells
Copy link

For me, it appears that the mandatorySignIn option set to true was causing this issue. Removed it and the No credentials, applicationId or region went away

Amplify.configure({
  Auth: {
    // mandatorySignIn: true,
    region: cognito.REGION,
    userPoolId: cognito.USER_POOL_ID,
    identityPoolId: cognito.IDENTITY_POOL_ID,
    userPoolWebClientId: cognito.APP_CLIENT_ID,
  },
  aws_appsync_graphqlEndpoint,
  aws_appsync_region,
  aws_appsync_authenticationType,
})

@lukehillonline
Copy link

lukehillonline commented Nov 20, 2020

Hey all, I am having this same issue and I have tried everything from all threads to get this working but I cannot. I have an existing project that has been running for many months using Amplify for API calls and user authentication, we are looking to move away from GA to Pinpoint for Web Analytics and in doing so have introduced analytics into our codebase.

I get the following error:

Error: No credentials, applicationId or region
    at AWSPinpointProvider.<anonymous> (AWSPinpointProvider.js:174)
    at step (AWSPinpointProvider.js:55)
    at Object.next (AWSPinpointProvider.js:36)
    at fulfilled (AWSPinpointProvider.js:27)

Here is my code:

    "@aws-amplify/analytics": "^3.3.11",
    "@aws-amplify/api": "^3.2.11",
    "@aws-amplify/auth": "^3.4.11",
import API from '@aws-amplify/api';
import Auth from '@aws-amplify/auth';
import Analytics from '@aws-amplify/analytics';

API.configure({
  endpoints: [
    {
      name: xxxx,
      endpoint: xxxx,
    },
  ],
});

Auth.configure({
  identityPoolId: xxxx,
  region: xxxx,
  userPoolId: xxxx,
  userPoolWebClientId: xxxx,
});

Analytics.configure({
  disabled: false,
  autoSessionRecord: true,
  AWSPinpoint: {
    appId: xxxx',
    region: xxxx,
    mandatorySignIn: false,
  },
});

export default function MyApp({ Component, pageProps }) {
  //Record an event
  const track = async () => {
    try {
      await Analytics.record({ name: 'test-event' });
    } catch (e) {
      console.log(e);
    }
  };

  useEffect(() => {
    track();
  }, []);

  return (
    <App>
      <Component {...pageProps} />}
    </App>
  );
}

I have tried all of the recommended fixes like checking for a capital I on identityPoolId or changing the import from @aws-amplify to aws-amplify or importing them all through { API, Auth, Analytics } from 'aws-amplify and so on but nothing has resolved it for me.

Any help I can get would be greatly appreciated.

@icecog
Copy link

icecog commented Nov 21, 2020

Hey guys,
I've been fighting Amplify for several days now and I must say I am not impressed with its documentation... it really makes me question the wisdom of going this route - I'm sorry to say.

But I hava a working prototype for Analytics now and thought I'd share my findings.
The error I was seeing was:

Uncaught (in promise) Error: No credentials, applicationId or region

This works for me (main/index/...):

import Amplify from '@aws-amplify/core';
import Analytics from '@aws-amplify/analytics';
import Auth from '@aws-amplify/auth';
import awsconfig from './aws-exports';

Amplify.configure(awsconfig);
Auth.configure({ mandatorySignIn: false});
Analytics.record({ name: 'bootup' });

Where the final nail was the:

Auth.configure({ mandatorySignIn: false});

Dependencies that works turned out to be:

 "dependencies": {
    "aws-amplify": "^3.3.9"
  }

I cannot be bothered to try out all the other permutations of packages @aws-amplify/core, analytics, auth etc.
I hope this works for you too.

@ltaljaard
Copy link

If your auth type is API key then also check its validity from AWS console -> AWS AppSync -> chooses your API -> Settings -> scroll down to Default authorization mode -> check that it has not expired there.

@icecog
Copy link

icecog commented Nov 22, 2020

I was just doing the basic walkthrough and selected the option of 'guests or unauthorized users' when adding the analytics.
That should probably set some flag somewhere in the project to avoid me having to specify the mandatorySignIn setting in Auth

Auth.configure({ mandatorySignIn: false});

oh, and here is my version

amplify version 4.32.1

But I'll keep that in mind going forward

@lukehillonline
Copy link

So I managed to resolve the issue for me. Instead of doing this

import API from '@aws-amplify/api';
import Auth from '@aws-amplify/auth';
import Analytics from '@aws-amplify/analytics';

I now do this
import { API, Auth, Analytics } from 'aws-amplify';

As I said in my comment before I had tried this in the past. The difference this time is I actually uninstalled anything related to @aws-amplify. If both @aws-amplify and aws-amplify are in your node_modules then the issue will persist.

While this is a fix, it's not a fix I am particularly happy with, I now have to import the entire amplify package to have this working rather than individual packages. I'm also not really sure why there is a difference between @aws-amplify and aws-amplify.

@anujmv
Copy link

anujmv commented Nov 24, 2020

If your auth type is API key then also check its validity from AWS console -> AWS AppSync -> chooses your API -> Settings -> scroll down to Default authorization mode -> check that it has not expired there.

No. its not expired but throwing up error - >

GraphQLAPI - ensure credentials error No Cognito Identity pool provided for unauthenticated access

Build error occurred
Error: No credentials

@sammartinez sammartinez added to-be-reproduced Used in order for Amplify to reproduce said issue and removed not-reproducible Not able to reproduce the issue labels Nov 27, 2020
@sammartinez
Copy link
Contributor

So I managed to resolve the issue for me. Instead of doing this

import API from '@aws-amplify/api';
import Auth from '@aws-amplify/auth';
import Analytics from '@aws-amplify/analytics';

I now do this
import { API, Auth, Analytics } from 'aws-amplify';

As I said in my comment before I had tried this in the past. The difference this time is I actually uninstalled anything related to @aws-amplify. If both @aws-amplify and aws-amplify are in your node_modules then the issue will persist.

While this is a fix, it's not a fix I am particularly happy with, I now have to import the entire amplify package to have this working rather than individual packages. I'm also not really sure why there is a difference between @aws-amplify and aws-amplify.

Thank you for this feedback @lukehillonline. As of now, this is what we recommend in order to solve your issue. I apologize this is not ideal but we believe the issue is with regards to how dependencies are being referenced when installing individual packages, which leads to triggering this error. You do have the ability to pin specific versions of each package if you would like to, however when a production build is done, any modules that are not in use will be tree shaken out.

@joebernard
Copy link

With help from the Amplify team, I fixed this issue by rolling back to these specific module versions, clearing yarn cache, cleaning the build, deleting node_modules, and yarn install everything fresh. I no longer get this error.

"@aws-amplify/analytics": "3.3.11",
"@aws-amplify/auth": "3.4.11",
"@aws-amplify/cache": "3.1.36",
"@aws-amplify/core": "3.8.3",
"@aws-amplify/storage": "3.3.11",
"amazon-cognito-identity-js": "4.5.4",

@AbirAbbas
Copy link

With help from the Amplify team, I fixed this issue by rolling back to these specific module versions, clearing yarn cache, cleaning the build, deleting node_modules, and yarn install everything fresh. I no longer get this error.

"@aws-amplify/analytics": "3.3.11",
"@aws-amplify/auth": "3.4.11",
"@aws-amplify/cache": "3.1.36",
"@aws-amplify/core": "3.8.3",
"@aws-amplify/storage": "3.3.11",
"amazon-cognito-identity-js": "4.5.4",

This worked for me, thanks!

@sammartinez sammartinez removed the to-be-reproduced Used in order for Amplify to reproduce said issue label Feb 9, 2021
@sammartinez
Copy link
Contributor

sammartinez commented Feb 9, 2021

Resolving as the above statement is the solution

@ahtokca
Copy link

ahtokca commented Mar 19, 2021

Got the issue with latest version. Is there any fresh solution? Fresher than 11 Dec 2020?

@ahtokca
Copy link

ahtokca commented Mar 19, 2021

After

npm uninstall \
  aws-amplify \
  aws-amplify-react \
  aws-amplify-react-native \
  aws-appsync aws-sdk \
  "@aws-amplify/analytics" \
  "@aws-amplify/api" \
  "@aws-amplify/auth" \
  "@aws-amplify/core" \
  "@aws-amplify/pushnotification" \
  "@aws-amplify/storage"

npm install --save \
  aws-amplify \
  aws-amplify-react \
  aws-amplify-react-native \
  aws-appsync aws-sdk \
  "@aws-amplify/analytics" \
  "@aws-amplify/api" \
  "@aws-amplify/auth" \
  "@aws-amplify/core" \
  "@aws-amplify/pushnotification" \
  "@aws-amplify/storage"

it works again

@plus-
Copy link

plus- commented Jun 9, 2021

So I managed to resolve the issue for me. Instead of doing this

import API from '@aws-amplify/api';
import Auth from '@aws-amplify/auth';
import Analytics from '@aws-amplify/analytics';

I now do this
import { API, Auth, Analytics } from 'aws-amplify';
As I said in my comment before I had tried this in the past. The difference this time is I actually uninstalled anything related to @aws-amplify. If both @aws-amplify and aws-amplify are in your node_modules then the issue will persist.
While this is a fix, it's not a fix I am particularly happy with, I now have to import the entire amplify package to have this working rather than individual packages. I'm also not really sure why there is a difference between @aws-amplify and aws-amplify.

Thank you for this feedback @lukehillonline. As of now, this is what we recommend in order to solve your issue. I apologize this is not ideal but we believe the issue is with regards to how dependencies are being referenced when installing individual packages, which leads to triggering this error. You do have the ability to pin specific versions of each package if you would like to, however when a production build is done, any modules that are not in use will be tree shaken out.

Hello, is this still applicable with 4.0.x ? (we are on 4.0.3)

We are trying to iron out the errors at startup in a react-native application and we have both the require cycle coming from the 'aws-amplify' import as well as this issue. Both having a solution/workaround incompatible with each other.

Require cycle: ../../node_modules/@aws-amplify/pubsub/lib-esm/index.js -> ../../node_modules/@aws-amplify/pubsub/lib-esm/PubSub.js -> ../../node_modules/@aws-amplify/pubsub/lib-esm/Providers/index.js -> ../../node_modules/@aws-amplify/pubsub/lib-esm/Providers/AWSAppSyncRealTimeProvider.js -> ../../node_modules/@aws-amplify/pubsub/lib-esm/index.js

WARN Possible Unhandled Promise Rejection (id: 0):
Error: No credentials, applicationId or region

@kornatskyi
Copy link

kornatskyi commented Jun 30, 2021

If you don't use Analytics disable it like this. Acording to the docs. Solved for me.
Amplify.configure({ ...config, Analytics: { disabled: true, } });

@samuthekid
Copy link

For those of us who NEED Analytics:

Background: I was trying to use this in an Expo React-Native app, but I was getting this error when associating a token with a user (Analytics.updateEndpoint({ ... })) and using @aws-amplify/xxx.

I installed aws-amplify and everything worked fine. So I opened the yarn.lock to see the dependencies versions of the main package.

Turn out this looks like a version mismatch, because this actually worked out for me:

    "@aws-amplify/analytics": "5.2.0",
    "@aws-amplify/auth": "4.4.2",
    "@aws-amplify/core": "4.4.0",
    "@aws-amplify/ui-components": "^1.9.6",
    "amazon-cognito-identity-js": "^5.2.6",

@orome
Copy link

orome commented May 26, 2022

If you don't use Analytics disable it like this. Acording to the docs. Solved for me.
Amplify.configure({ ...config, Analytics: { disabled: true, } });

How are we supposed to know this? Where is it documented?

@nikitaSazhinov
Copy link

Hello,

I have been having this issue for quite a while, followed as far as I know all the threads that offer solutions.
I am using Expo (46) with Amplify. I think I have tried pretty much every combination of packages, package versions, import types but if it solves one problem it creates another.

On some versions of Amplify I get the "Error: No credentials, applicationId or region", on others it is an issue with Pinpoint and maximum number being exceeded (we am using analytics, so the disable analytics solution is a non-solution). These all happen when using Amplify version 3.x.x. When I try to update to 4 or 5, these issues seemingly disappear, however then the whole application just crushes on the Amplify.configure (this only happens in production mode also, so very frustrating to debug)

Is there anybody who does use Analytics in their Expo app and has been able to solve this issue? I am getting quite desperate with this now.

I can provide my package.json, but for now I left it out as I already tried multiple versions, combinations of versions and packages to try to solve this issue without any success.

@dinesh-brilworks
Copy link

dinesh-brilworks commented Oct 20, 2023

I am having same issue while log analytics events,

Analytics.record

Using following dependancies,

    "aws-amplify": "~5.3.11",
    "aws-amplify-react-native": "~7.0.7",

using s3,

"@aws-sdk/client-s3": "~3.370.0",

@julian-kingman-lark
Copy link

I'm having this issue consistently. Downgrading aws-amplify is not really an option, and many imports available in @aws-amplify/[package] packages are not available as exports of aws-amplify, so I can't test that solution. And yes, I just have the single aws-amplify package installed, and have tried the options given so far.

I think it's working OK, but the logs are very irritating and make debugging a chore.

@cwomack
Copy link
Contributor

cwomack commented Mar 1, 2024

@julian-kingman-lark and @dinesh-brilworks (or anyone else on this issue), are you still experiencing this in the latest versions of Amplify v.5X? Or can anyone confirm if they still experience this issue after upgrading to v6 (latest major version) using the v6 API's?

@toddaa
Copy link

toddaa commented Mar 7, 2024

@julian-kingman-lark and @dinesh-brilworks (or anyone else on this issue), are you still experiencing this in the latest versions of Amplify v.5X? Or can anyone confirm if they still experience this issue after upgrading to v6 (latest major version) using the v6 API's?

@cwomack Unfortunately, I am. I have not had time to upgrade from 5x to 6x (that's not entirely true, I have that incomplete effort in a separate branch), but needed to turn on Analytics this week. I am getting the same error as the rest and am hunting for the answer. If you have any workaround for the 5x version I'd love to hear it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Analytics Related to analytics React Native React Native related issue
Projects
None yet
Development

No branches or pull requests