Search code examples
amazon-web-servicesreact-nativeaws-amplify

AWS Amplify React Native, GET request error 403 status code


I enabled access to unauthenticated identities to do some quick testing before integrating authentication. My configuration code is the following,

Amplify.configure({
Auth: {
    identityPoolId: 'us-east-1:example',
    region: 'us-east-1',
    userPoolId: 'us-east-1_example',
    userPoolWebClientId: 'us-east-1_example'
},
API: {
    endpoints: [
        {
            name: "example-name",
            endpoint: "https://example.execute-api.us-east-1.amazonaws.com/prod/example-path"
        },
    ]
}
});

and my GET request code is the following,

example() {
const apiName = 'example-name';
const path = '/example-path';

API.get(apiName, path).then(response => {
  console.log(response)
}).catch(error => {
  console.log(error)
})
}

I followed everything on GitHub and my API gateway and Lambda functions are working correctly when I run a "test" and through postman. But on react-native it's giving me a 403 status code without any detailed explanation. Does this have to do with accessing using unauthenticated identity? Also, I used "example" in my code to hide my personal information, I typed in everything correctly since I'm not getting any syntax error (identity pool recognizes access every time I run it, but cloudWatch doesn't show any log of gateway access)


Solution

  • The Endpoint in Amplify.configure is the InvokeURL from API Gateway, you just need to include the stage (/prod in this case) and not the other routes. The other routes are just the path parameters for API.() calls.