aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.41k stars 2.12k forks source link

API 403 error on api-rest calls after recent upgrade #6492

Closed sadooghi closed 4 years ago

sadooghi commented 4 years ago

Describe the bug When upgrading from aws-amplify @3.0.17 to @3.0.22 my REST APIs that need authorization all get back 403 errors. This is solved by downgrading api-rest to 1.0.18. I think the errors starts when upgrading from api-rest 1.0.18 to 1.1.0

To Reproduce Using previously created aws-export.js, upgrade from api-rest 1.0.18 to latest api-reset

Expected behavior Should not show 403 errors with existing api.

Code Snippet Please provide a code snippet or a link to sample code of the issue you are experiencing to help us reproduce the issue. (Be sure to remove any sensitive data)

Screenshots If applicable, add screenshots to help explain your problem.

What is Configured? If applicable, please provide what is configured for Amplify CLI:

Environment ``` npx envinfo --system --binaries --browsers --npmPackages --npmGlobalPackages ```

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

_You can turn on the debug mode to provide more info for us by setting window.LOGLEVEL = 'DEBUG'; in your app.

amhinson commented 4 years ago

Could you also share your package.json?

sadooghi commented 4 years ago

@amhinson

just a note I did use migrator to migrate from mobile hub to amplify

Could you also share your package.json?

"version": "0.0.1",
"private": true,
"scripts": {
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"@aws-amplify/core": "^3.3.3",
"@react-native-community/art": "^1.2.0",
"@react-native-community/datetimepicker": "^2.6.1",
"@react-native-community/masked-view": "^0.1.10",
"@react-native-firebase/admob": "^7.4.1",
"@react-native-firebase/analytics": "^7.4.1",
"@react-native-firebase/app": "^8.3.0",
"@react-native-firebase/crashlytics": "^8.3.0",
"amazon-cognito-identity-js": "^3.2.0",
"aws-amplify": "^3.0.17",
"axios": "^0.19.2",
"barcode-reader": "^1.6.1",
"buffer": "^5.6.0",
"create-react-class": "^15.6.3",
"moment": "^2.27.0",
"native-base": "^2.13.13",
"react": "16.13.1",
"react-lifecycles-compat": "^3.0.4",
"react-native": "^0.63.2",
"react-native-dotenv": "^0.2.0",
"react-native-fs": "^2.16.6",
"react-native-mime-types": "^2.2.1",
"react-native-multi-range": "^0.1.0",
"react-native-onesignal": "^3.9.0",
"react-native-popup-menu": "^0.15.9",
"react-native-reanimated": "^1.10.2",
"react-native-safe-area-context": "^3.1.4",
"react-native-screens": "^2.10.1",
"react-native-selectmultiple-button": "^0.1.105",
"react-native-share": "^3.7.0",
"react-native-speedometer": "^1.0.3",
"react-native-step-indicator": "^1.0.3",
"react-native-webview": "^10.4.0",
"react-navigation": "^4.4.0",
"react-navigation-hooks": "^1.1.0",
"react-navigation-stack": "^2.8.2",
"react-navigation-tabs": "^2.9.0",
"react-redux": "^7.2.1",
"react-timer-mixin": "^0.13.4",
"redux": "^4.0.5",
"redux-actions": "^2.6.5",
"redux-thunk": "^2.3.0",
"rn-fetch-blob": "^0.12.0",
"save": "^2.4.0",
"seedrandom": "^3.0.5"
},
"devDependencies": {
"@babel/core": "^7.8.4",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.2.0",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
"@babel/preset-env": "^7.2.3",
"@babel/preset-flow": "^7.0.0",
"@babel/runtime": "^7.8.4",
"@react-native-community/eslint-config": "^1.1.0",
"babel-jest": "^25.1.0",
"babel-plugin-import": "^1.6.3",
"babel-plugin-transform-remove-console": "^6.9.4",
"hermes-engine": "^0.5.0",
"jest": "^25.1.0",
"jetifier": "^1.6.6",
"metro": "^0.55.0",
"metro-react-native-babel-preset": "^0.59.0",
"react-test-renderer": "16.13.1"
},
"jest": {
"preset": "react-native"
}
} 
amhinson commented 4 years ago

Are you using an API from Amplify? Could you post your configuration/usage as well? If not, could you explain more about your API?

Also, you can remove the @aws-amplify/core dependency, as it is already included in aws-amplify. Sometimes having different version in your package.json can cause issues. After removing it, I'd recommend deleting your node_modules and reinstalling.

sadooghi commented 4 years ago

removing @aws-amplify/core solved the issue thank you.

Only note is aws-amplify 3.0.22 imports core by default, 3.0.23 did not for me.

sadooghi commented 4 years ago

reopening just for the last point i.e. 3.0.23 didn't import core automatically.

amhinson commented 4 years ago

Could you elaborate a bit on what you're seeing? @aws-amplify/core is a dependency of aws-amplify so it should be getting used. I'd also recommend deleting your node modules and reinstalling.

sadooghi commented 4 years ago

I did uninstall and reinstall all packages but when I did 3.0.23 app crashed saying dependencies core was missing, did the same with 3.0.22 but it worked.

amhinson commented 4 years ago

Are you importing anything in your project directly from @aws-amplify/core? If so, you can now just import it from aws-amplify

sadooghi commented 4 years ago

I am not (after removing core), but maybe it's just my own issue?

github-actions[bot] commented 3 years ago

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.