Closed PriyaranjanEuphotic closed 1 year ago
Hi @PriyaranjanEuphotic thanks for posting this issue.
Are you able to verify that the delete request is actually succeeding on both platforms? Are all other requests succeeding on both platforms or are they just completing without throwing any errors?
ya I tried delete request in both devices but, getting success in ios but failed in android. other requests are working fine like post, put, get, etc.
Hi @PriyaranjanEuphotic what instructions did you follow to setup the auth of your REST API?
Can you provide your amplify config file with the sensitive keys redacted?
This extensive issue here might be related depending on if your setup is similar: https://github.com/aws-amplify/amplify-flutter/issues/1539
@PriyaranjanEuphotic another question for you: When you say HTTP GET, POST working, is your code that sends those requests using the same logic as example with DELETE to supply the HTTP header with the ID token? The error message seems to indicate some server-side error with IAM authentication, which it appears you are trying to override with Cognito user pools auth, so I wasn't sure if working methods (GET, POST) were using IAM.
Without a little more info about use case, here's what I was able to determine about REST API in this android use case: Reported error is expected behavior if trying to custom authorize a request on backend/amplify config that otherwise use IAM (e.g. sign the request with AWS credentials, default auth mode for REST API). That's because the Android's IAM request decorator does not short-circuit if there is already an "Authorization" parameter set, resulting in an incorrectly signed request which throws a server-side error. Note that in the dev preview version and iOS, this is a little difference that the client won't sign a request with an "Authorization" header set. You could try renaming the header something else so it doesn't interfere with signing like "My-Authorization". If you don't want the client to sign the request at all, you could setup a different auth mode. Then, there is some work to make the backend accept new Auth schema either way as the CLI only supports IAM mode by default.
Let me know if this answers your question about the error you got.
Hi, I tried with "amplify_api: ^0.5.1" everything working fine. but with version 0.6.12 delete request is not working
Hi @PriyaranjanEuphotic thanks for that information, in order to better help you here can you please answer the above questions though. We are guessing at what you might have done and proposing solutions based on that.
1) How are you authorizing requests, are you using the default authorization rules with IAM authorization? Or are you using cognito user pools / api key / oidc / custom http request headers?
https://docs.amplify.aws/lib/restapi/authz/q/platform/flutter/
2) Is the code that sends HTTP GET, POST requests using the same logic as DELETE? Is the supplied HTTP header with ID token the same?
@PriyaranjanEuphotic - If you are still facing this issue, please provide the info requested above. Thanks.
@PriyaranjanEuphotic - I an going to close this out since we have not heard back. If you are still facing this issue, please provide the info request above.
Description
Future removeId({
required String id,
}) async {
CognitoAuthSession session = await Amplify.Auth.fetchAuthSession(
options: CognitoSessionOptions(getAWSCredentials: true))
as CognitoAuthSession;
Error: - {"message":"Authorization header requires 'Credential' parameter. Authorization header requires 'Signature' parameter. Authorization header requires 'SignedHeaders' parameter. Authorization header requires existence of either a 'X-Amz-Date' or a 'Date' header. Authorization=eyJraWQiOiJreDVUUTBFbXk3Vlwvd0E5akpvQ0tcL3hrSjJOSlIwYmRPZlFNc0daR1o4VUU9IiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiJkMDY3MTU5Yy01MjJiLTRjYjYtOTU2Yi0zNTg3MDFmNDUyNmYiLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLmFwLXNvdXRoLTEuYW1hem9uYXdzLmNvbVwvYXAtc291dGgtMV9LQ0x1MUpPREgiLCJjb2duaXRvOnVzZXJuYW1lIjoiZDA2NzE1OWMtNTIyYi00Y2I2LTk1NmItMzU4NzAxZjQ1MjZmIiwiYXVkIjoiMW5hdnZra2pnYmUzOGNxNGZraWEyYTVlOXIiLCJldmVudF9pZCI6IjBlYjlkZDQ5LTcxNmEtNDY3YS04NThkLTZhNjQxYjA4MTQ0ZSIsInRva2VuX3VzZSI6ImlkIiwiYXV0aF90aW1lIjoxNjc1MTUyMTc0LCJuYW1lIjoiUHJpeWFyYW5qYW4iLCJleHAiOjE2NzUxNTU3NzQsImlhdCI6MTY3NTE1MjE3NCwiZW1haWwiOiJwcml5YXJhbmphbkBldXBob3RpYy5pbyJ9.f4Reb6o637goGmSlxXm73wCMM01mR1vDCfPvdsbCBFTWhy98uvVs3_aM3v6O8IiFvPigB3yDzR8X9C7sn5fshfdUndT0CnrBUO41ZT59bUc9cIQpHVeBRNTLcoAn8MHIlwJptm33l1EKr3nDAKnnmxDLok6kLAz5Yy9KIdTsMveUebSD980QwhPA7AwOAHh61WQWkyQ5hm_uy3bbsXr7JD_JMsxme8Y66DJ-QwOfIUesJkV8XcjgERgdW1sn2V0QFcwdD17xn-4nUcpBVeMOw9gYYN9iiXb38voqR-jih6_j2NENZ18ZWAChF0iIe8rWV6J0yKZ1iiokJ8BBJPxgRA"}
While I am trying to perform above operation, I'm getting following error.
I am not getting any error with get, post and put request.
Categories
Steps to Reproduce
No response
Screenshots
No response
Platforms
Android Device/Emulator API Level
No response
Environment
Dependencies
Device
Pixel 3a
OS
Android 12
Deployment Method
Amplify CLI + Custom Pipeline
CLI Version
No response
Additional Context
No response
Amplify Config