{"action":"closed","issue":{"url":"https://api.github.com/repos/aws/aws-sdk-js/issues/1489","repository_url":"https://api.github.com/repos/aws/aws-sdk-js","labels_url":"https://api.github.com/repos/aws/aws-sdk-js/issues/1489/labels{/name}","comments_url":"https://api.github.com/repos/aws/aws-sdk-js/issues/1489/comments","events_url":"https://api.github.com/repos/aws/aws-sdk-js/issues/1489/events","html_url":"https://github.com/aws/aws-sdk-js/issues/1489","id":225101973,"number":1489,"title":"[React-Native] DynamoDB throwing Error: Missing credentials in config at Request.VALIDATE_REGION","user":{"login":"MattyK14","id":16196171,"avatar_url":"https://avatars1.githubusercontent.com/u/16196171?v=3","gravatar_id":"","url":"https://api.github.com/users/MattyK14","html_url":"https://github.com/MattyK14","followers_url":"https://api.github.com/users/MattyK14/followers","following_url":"https://api.github.com/users/MattyK14/following{/other_user}","gists_url":"https://api.github.com/users/MattyK14/gists{/gist_id}","starred_url":"https://api.github.com/users/MattyK14/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MattyK14/subscriptions","organizations_url":"https://api.github.com/users/MattyK14/orgs","repos_url":"https://api.github.com/users/MattyK14/repos","events_url":"https://api.github.com/users/MattyK14/events{/privacy}","received_events_url":"https://api.github.com/users/MattyK14/received_events","type":"User","site_admin":false},"labels":[{"id":13276310,"url":"https://api.github.com/repos/aws/aws-sdk-js/labels/Question","name":"Question","color":"cc317c","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2017-04-28T14:43:07Z","updated_at":"2017-05-02T14:16:00Z","closed_at":"2017-05-02T14:16:00Z","body":"I'm trying to do a batchGetItem with DynamoDB on react-native and it's throwing the following error:\r\n\r\n```\r\nError: Missing credentials in config\r\n    at Request.VALIDATE_REGION (aws-sdk-react-native.js:10326)\r\n    at Request.callListeners (aws-sdk-react-native.js:10112)\r\n    at Request.emit (aws-sdk-react-native.js:10084)\r\n    at Request.emit (aws-sdk-react-native.js:14062)\r\n    at Request.transition (aws-sdk-react-native.js:13413)\r\n    at AcceptorStateMachine.runTo (aws-sdk-react-native.js:14199)\r\n    at Request.runTo (aws-sdk-react-native.js:13788)\r\n    at Request.send (aws-sdk-react-native.js:13752)\r\n    at features.constructor.makeUnauthenticatedRequest (aws-sdk-react-native.js:6689)\r\n    at features.constructor.getId (aws-sdk-react-native.js:9118) \"ConfigError: Missing credentials in config\r\n    at Request.VALIDATE_REGION (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:89572:43)\r\n    at Request.callListeners (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:89495:17)\r\n    at Request.emit (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:89470:10)\r\n    at Request.emit (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:92539:15)\r\n    at Request.transition (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:92283:11)\r\n    at AcceptorStateMachine.runTo (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:92642:13)\r\n    at Request.runTo (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:92362:16)\r\n    at Request.send (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:92352:11)\r\n    at features.constructor.makeUnauthenticatedRequest (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:87518:31)\r\n    at features.constructor.getId (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:88786:17)\"\r\n```\r\n\r\nSo I'm just rendering a simple screen with 2 buttons for testing purposes right now, but button 1 authenticates the Cognito user using [react-native-aws-cognito-js](https://github.com/AirLabsTeam/react-native-aws-cognito-js) successfully.\r\n\r\nHere's the relevant code: \r\n\r\n```\r\n    import { Config, CognitoIdentityCredentials, DynamoDB } from 'aws-sdk/dist/aws-sdk-react-native';\r\n    import { AuthenticationDetails, CognitoUser, CognitoUserPool, CognitoUserAttribute } from 'react-native-aws-cognito-js';\r\n\r\n    const appConfig = {\r\n      region: 'us-east-1',\r\n      IdentityPoolId: 'us-east-1:foo-bar',\r\n      UserPoolId: 'us-east-1_foo-bar',\r\n      ClientId: '1f2o3o4b5a6r',\r\n    };\r\n\r\n    Config.region = appConfig.region;\r\n\r\n    class AWS_testpage extends Component {\r\n\r\n      constructor(props) {\r\n        super(props);\r\n\r\n        this.state = {\r\n          username: 'someUsername',\r\n          password: 'somePassword',\r\n        };\r\n\r\n    login() {\r\n        const { username, password } = this.state;\r\n\r\n        const authenticationData = {\r\n          Username: username,\r\n          Password: password,\r\n        };\r\n\r\n        const authenticationDetails = new AuthenticationDetails(authenticationData);\r\n\r\n        const poolData = {\r\n          UserPoolId: appConfig.UserPoolId,\r\n          ClientId: appConfig.ClientId\r\n        };\r\n\r\n        const userPool = new CognitoUserPool(poolData);\r\n        console.log('USERPOOOL', userPool);\r\n\r\n        const userData = {\r\n          Username: username,\r\n          Pool: userPool\r\n        };\r\n\r\n        const cognitoUser = new CognitoUser(userData);\r\n\r\n        cognitoUser.authenticateUser(authenticationDetails, {\r\n          onSuccess: (result) => {\r\n            console.log(`ACCESS TOKEN =====> ${result.getAccessToken().getJwtToken()}`);\r\n            Config.credentials = new CognitoIdentityCredentials({\r\n              IdentityPoolId: appConfig.IdentityPoolId,\r\n              Logins: {\r\n                [`cognito-idp.${appConfig.region}.amazonaws.com/${appConfig.UserPoolId}`]: result.getIdToken().getJwtToken()\r\n              }\r\n            });\r\n\r\n            alert('Success');\r\n          },\r\n          onFailure: (error) => {\r\n            alert(error);\r\n          },\r\n          newPasswordRequired: () => {\r\n            console.log('NEW PASSWORD REQUIRED');\r\n          }\r\n        });\r\n      }\r\n\r\n    onDynamoPress() {\r\n        const dynamodb = new DynamoDB(Config);\r\n        console.log('DYNAMODB', dynamodb);\r\n\r\n\r\n        const paramsDB = {\r\n        RequestItems: {\r\n        Readings: {\r\n        Keys: [{\r\n          hwid: {\r\n            S: 'ThisIsFake'\r\n          },\r\n          timestamp: {\r\n            S: 'Now'\r\n          }\r\n        }],\r\n        ProjectionExpression: 'received' // this is what element you want back\r\n      }\r\n    }\r\n  };\r\n\r\n  dynamodb.batchGetItem(paramsDB, (err, data) => {\r\n    if (err) console.log(err, err.stack); // an error occurred\r\n    else console.log(data);           // successful response\r\n\r\n  });\r\n}\r\n```\r\n\r\nIf I attempt the batchGetItem without authenticating, it throws the following:\r\n\r\n```\r\nError: Missing credentials in config\r\n    at credError (aws-sdk-react-native.js:7490)\r\n    at Config.getCredentials (aws-sdk-react-native.js:7529)\r\n    at Request.VALIDATE_CREDENTIALS (aws-sdk-react-native.js:10313)\r\n    at Request.callListeners (aws-sdk-react-native.js:10108)\r\n    at Request.emit (aws-sdk-react-native.js:10084)\r\n    at Request.emit (aws-sdk-react-native.js:14062)\r\n    at Request.transition (aws-sdk-react-native.js:13413)\r\n    at AcceptorStateMachine.runTo (aws-sdk-react-native.js:14199)\r\n    at Request.runTo (aws-sdk-react-native.js:13788)\r\n    at Request.send (aws-sdk-react-native.js:13752) \"CredentialsError: Missing credentials in config\r\n```"}}
{"actor":{"display_login":"MattyK14"}}