2

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)

6
  • Have you tried using a different package like superagent or axios? I've had this issue with RN, (postman worked fine). Commented Jan 2, 2018 at 2:56
  • I'll give it a try! Were you able to work your way around? Commented Jan 2, 2018 at 3:04
  • yea, I was using react native fetch blob which was screwing up Fetch. using axios and refacting things (because axios responses look different) it worked. Commented Jan 2, 2018 at 3:08
  • @GavinThomas Thanks and have you tried it on RN with authenticated identity (with cognito auth)? Commented Jan 2, 2018 at 3:25
  • @GavinThomas I ended up getting it working. I had to get rid of the path name ('example-path') from the endpoint url. It was being duplicated Commented Jan 2, 2018 at 3:37

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.