Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook Login using Exponent React Native

Tags:

Need help guys, currently using exponent and accessing the Exponent.Facebook.logInWithReadPermissionsAsync for authentication. Anyone has a guide in setting up the project. I can't find the iOS folder since in the instruction of facebook sdk, I need to add few libraries on the project. Here's my main.js:

import Expo from 'expo';
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { Button } from 'react-native-elements';

class App extends React.Component {

  authenticate = (token) => {
    const provider = firebase.auth.FacebookAuthProvider;
    const credential = provider.credential(token);
    return firebase.auth().signInWithCredential(credential);
  }

  login = async () => {
    const ADD_ID = 273131576444313
    const options = {
        permissions: ['public_profile', 'email'],
    }
    const {type, token} = await Expo.Facebook.logInWithReadPermissionsAsync(ADD_ID, options)
    if (type === 'success') {
        const response = await fetch(`https://graph.facebook.com/me?access_token=${token}`)
        console.log(await response.json());
        this.authenticate(token);
    }
}

  render() {
    return (
      <View style={styles.container}>
        <Text>Open up main.js to start working on your app!</Text>
        <Button
          raised
          onPress={this.login}
          icon={{name: 'cached'}}
          title='RAISED WITH ICON' />
      </View>
    );
  }

}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
});

Expo.registerRootComponent(App);

`

like image 463
Ruie Pena Avatar asked Mar 24 '17 10:03

Ruie Pena


1 Answers

Try putting single quotes around the APP_ID

like image 140
Roy Lara Avatar answered Sep 24 '22 10:09

Roy Lara