I am trying to use the react native FBDSK Wrapper library along with the AWS cognito javascript library (recently switched react native support over to the js library)
I am able to login with FB and retrieve the token but when I try to sign in using AWS cognito I do not see a succesful login in my AWS federated identity dashboard. I am wondering what am I doing wrong here?
index.js :
import React, { Component } from 'react';
import {
Animated,
Platform,
StatusBar,
StyleSheet,
Text,
View,
Image,
TouchableHighlight,
} from 'react-native';
var AWS = require('aws-sdk/dist/aws-sdk-react-native');
const FBSDK = require('react-native-fbsdk');
const {
LoginButton,
AccessToken
} = FBSDK;
var Login = React.createClass({
render: function() {
return (
<View>
<LoginButton
publishPermissions={["publish_actions"]}
onLoginFinished={
(error, result) => {
if (error) {
alert("Login failed with error: " + result.error);
} else if (result.isCancelled) {
alert("Login was cancelled");
} else {
alert("Login was successful with permissions: " + result.grantedPermissions)
AccessToken.getCurrentAccessToken().then(
(data) => {
AWS.config.region = 'us-east-1';
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId: 'us-east-xxxxxxxxxxxxxxxxxxxxxx',
Logins: {
'graph.facebook.com': data.accessToken.toString()
}
},
alert(data.accessToken.toString()) // I am able to see the access token so I know i am getting it succesfully
);
}
)
}
}
}
onLogoutFinished={() => alert("User logged out")}/>
</View>
);
}
});
export default class App extends Component {
render() {
return (
<View>
<Text>Welcome to the Facebook SDK for React Native!</Text>
<Login />
</View>
);
}
}