2

When I try to launch my react-native project I get the following error: AWSPinpointProvider record event failed: Credentials error missing credentials in config. I am not using the record function yet, so I assume this is coming from the configure function. I'm new to react-native and AWS pinpoint so where should I have the credentials configured? I have a ~/.aws/credentials and ~/.aws/config files and I can connect to cognito, it is only pinpoint that is causing problems. And of course I am using aws amplify. Any help would be appreciated.

import { withAuthenticator } from 'aws-amplify-react-native';  
import Auth from '@aws-amplify/auth';
import Analytics from '@aws-amplify/analytics';
import awsconfig from './aws-exports';
Auth.configure(awsconfig);
Analytics.configure(awsconfig);

I expect to see events like app launch in Pinpoint. I at least expect it not to crash the app.

Brad R
  • 21
  • 2
  • You don't need that line `Analytics.configure(awsconfig);`. Delete it :) **PS** Check out [this tutorial](https://geromekevin.com/tracking-and-email-reminders-in-aws-amplify/) I wrote, where I explain Analytics with Amplify. – J. Hesters Jul 16 '19 at 10:44

2 Answers2

1

When configuring your React-Native project with AWS Amplify for the first time (i.e using the command “amplify init”), you might seen a section on your terminal stating : "? Do you want to use an AWS profile? ( Y/n )"

*If you select “Y”, inside the “amplify/.config” folder a JSON file named “local-aws-info.json” will be created where your credentials will be obtained from. For this option, this “local-aws-info.json” file it's structure will resemble the following :

{
    "dev": {
        "configLevel": "project",
        "useProfile": true,
        "profileName": "syumaK"
    }
}

For this option, amplify will use the specified AWS profile when configuring awscli.

If you select “n”, you will be prompted to enter your “access-key”, “secret-key” & “region”. Inside the “amplify/.config” folder a JSON file named “local-aws-info.json” will be created where your credentials will be obtained from. For this option, this “local-aws-info.json” file it's structure will resemble the following :

{
    "dev": {
        "configLevel": "project",
        "useProfile": false,
        "awsConfigFilePath": "/Users/syumaK/.amplify/awscloudformation/AjWphtMBs0"
    }
}

Additionally my "App.js" file import statements look like the following :

import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { withAuthenticator } from 'aws-amplify-react-native';
import Amplify from '@aws-amplify/core';
import { Analytics } from 'aws-amplify'; 
import aws_exports from './aws-exports'; 
Amplify.configure(aws_exports); Analytics.configure(aws_exports);
window.LOG_LEVEL = 'DEBUG';

I have tested the above suggestion using the following environment spec:

  • OS : Mac High Sierra v10.13.6
  • "aws-amplify": "^1.1.28"
  • "aws-amplify-react-native": "^2.1.12"
  • "react": "16.8.3" "react-native": "0.59.9"
aksyuma
  • 2,957
  • 1
  • 15
  • 29
0

After reviewing the debug logs this is caused by having your auth config to not allow unauthenticated use of your app. A work around would be to set your auth in the amplify cli to allow unauthenticated use and use, for example, the withAuthenticator hoc to disallow getting into your app without auth.

loag
  • 588
  • 1
  • 7
  • 20