AWS Amplify: AmplifyException 'You are not authorized to make this call.'

6.6k Views Asked by At

I have integrated aws amplify into and android app by following https://docs.amplify.aws/lib/q/platform/android in my mac book pro.

Now I check-out the same project into another machine mac mini. and trying to run.

I am getting this error, not sure how to fix it.

AmplifyException {message=Failure performing sync query to AppSync: [GraphQLResponse.Error{message='You are not authorized to make this call.'

tried, amplify pull, amplify configure, amplify init. but none are able to resolve this issue.

thanks in advance

3

There are 3 best solutions below

3
On

Initially, you will see your graphql in Network tab failed because of Authorization.

"My case is App Sync API key is expried. – Freddie Jun 26"

This is the answer, go to Appsync / Settings / API keys.

You will see the "red" key. That means it has expired.

You just need to create a new key. Then replace this new key for appsync api inside your aws-exports.js under name aws_appsync_apiKey

If you have resolved this, I'll just leave it here so someone else can see it.

0
On

If your token expired (here I'm talking about a token that was living its max 365 days and has expired) and you by any chance are publishing your application to AWS using amplify, you will need to add new token to application (simply changing it in awsexports would not be enough). To do it you must:

  1. Find the file amplify/backend/<your_app_name>/parameters.json and there add two lines (this might be just CreateAPIKey but I've tested just one method found in this github issue and it worked).
   "APIKeyExpirationEpoch": -1,
   "CreateAPIKey": -1
  1. Run amplify push. This should delete the old token. But you will be better off checking it yourself in Appsync/settings/api keys. If you have no tokens there, then you are good to go.

  2. Go back to parameters.json file and remove our parameters (APIKeyExpirationEpoch and CreateAPIKey).

  3. Run amplify update api. Choose your api (mine was Graphql). Choose update auth settings. Choose your default authorization method (mine Api key). Enter description for your api key and add the ttl for your api key (default is 7 so I suggest changing this one). Don't configure additional auth types. enter image description here

  4. You should get success message at the end. Now do amplify push. After a while the command should return success message and you are good to go. To double check you can verify token in your appsync. There should be one token only. Alson you can check the api calls for x-api-key value in header which should hold your new token.

0
On

Ah! Great news, you can simply edit the date (no need to make a new one).

It's just that the default is one week.

Go to your ordinary, full, normal AWS console. GO to "aws appsync".

Then ..

enter image description here