Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript FB登录,带React Native+AWS Cognito_Javascript_React Native_Facebook Login_Aws Cognito - Fatal编程技术网

Javascript FB登录,带React Native+AWS Cognito

Javascript FB登录,带React Native+AWS Cognito,javascript,react-native,facebook-login,aws-cognito,Javascript,React Native,Facebook Login,Aws Cognito,我尝试使用react原生FBDSK包装库以及AWS cognito javascript库,最近将react原生支持切换到js库 我可以使用FB登录并检索令牌,但当我尝试使用AWS cognito登录时,在我的AWS federated identity仪表板中没有看到成功登录。我想知道我做错了什么 index.js: import React, { Component } from 'react'; import { Animated, Platform, StatusBar,

我尝试使用react原生FBDSK包装库以及AWS cognito javascript库,最近将react原生支持切换到js库

我可以使用FB登录并检索令牌,但当我尝试使用AWS cognito登录时,在我的AWS federated identity仪表板中没有看到成功登录。我想知道我做错了什么

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…

thnx,这是有效的!我只是假设如果FB登录成功,AWS会自动获取凭据。我不确定我们到底需要如何使用get函数来访问凭据。你能详细说明你的答案吗。我只是个初学者,这会很有帮助的。谢谢