FB 登录 w/ React Native + AWS Cognito
FB Login w/ React Native + AWS Cognito
我正在尝试将 React Native FBDSK Wrapper 库与 AWS Cognito javascript 库一起使用(最近将 React Native 支持切换到 js 库)
我可以使用 FB 登录并检索令牌,但是当我尝试使用 AWS cognito 登录时,我没有在我的 AWS 联合身份控制面板中看到成功登录。我想知道我在这里做错了什么?
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>
);
}
}
准备好 AWS.config.credentials =
后,您需要调用 AWS.config.credentials.get(()....)
我正在尝试将 React Native FBDSK Wrapper 库与 AWS Cognito javascript 库一起使用(最近将 React Native 支持切换到 js 库)
我可以使用 FB 登录并检索令牌,但是当我尝试使用 AWS cognito 登录时,我没有在我的 AWS 联合身份控制面板中看到成功登录。我想知道我在这里做错了什么?
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>
);
}
}
准备好 AWS.config.credentials =
后,您需要调用 AWS.config.credentials.get(()....)