簡體   English   中英

FB 登錄 w/ React Native + AWS Cognito

[英]FB Login w/ React Native + AWS Cognito

我正在嘗試將本機 FBDSK Wrapper 庫與 AWS cognito javascript 庫一起使用(最近將本機支持切換到 js 庫)

我可以使用 FB 登錄並檢索令牌,但是當我嘗試使用 AWS cognito 登錄時,我沒有在我的 AWS 聯合身份控制面板中看到成功登錄。 我想知道我在這里做錯了什么?

索引.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(()....)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM