Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React native Cannot pass a read permission (email) to a request for publish authorization

I am implementing fb sdk in react native app. I have done all changes from link, and running in android device. App crashes on Facebook login button click and these are logs.

05-23 10:42:20.559 7063-7063/com.fbsample E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.fbsample, PID: 7063
    Cannot pass a read permission (email) to a request for publish authorization
        at com.facebook.login.LoginManager.validatePublishPermissions(LoginManager.java:444)
        at com.facebook.login.LoginManager.logInWithPublishPermissions(LoginManager.java:416)
        at com.facebook.login.widget.LoginButton$LoginClickListener.performLogin(LoginButton.java:753)
        at com.facebook.login.widget.LoginButton$LoginClickListener.onClick(LoginButton.java:725)
        at com.facebook.FacebookButtonBase$1.onClick(FacebookButtonBase.java:384)
        at android.view.View.performClick(View.java:4785)
        at android.view.View$PerformClick.run(View.java:19884)
        at android.os.Handler.handleCallback(Handler.java:739)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:135)
        at android.app.ActivityThread.main(ActivityThread.java:5343)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)

I searched a lot but none helped me to get rid of this issue.

At least error should contain a suggestion to do.

I am stuck from hours :/

There is nothing new from facebook doc.

I have FBLoginButton.js

    import React, { Component } from 'react';
    import { View } from 'react-native';
    import { LoginButton } from 'react-native-fbsdk';

    export default class FBLoginButton extends Component {
      render() {
        return (
          <View>
            <LoginButton
              publishPermissions={["email"]}
              onLoginFinished={
                (error, result) => {
                  if (error) {
                    alert("Login failed with error: " + error.message);
                  } else if (result.isCancelled) {
                    alert("Login was cancelled");
                  } else {
                    alert("Login was successful with permissions: " + result.grantedPermissions)
                  }
                }
              }
              onLogoutFinished={() => alert("User logged out")}/>
          </View>
        );
      }
    };

    module.exports = FBLoginButton;

And App.js

import React, { Component } from 'react';
import {
  Platform,
  StyleSheet,
  Text,
  View
} from 'react-native';
var FBLoginButton = require('./FBLoginButton');
const instructions = Platform.select({
  ios: 'Press Cmd+R to reload,\n' +
    'Cmd+D or shake for dev menu',
  android: 'Double tap R on your keyboard to reload,\n' +
    'Shake or press menu button for dev menu',
});

type Props = {};
export default class App extends Component<Props> {
  render() {
    return (
      <View style={styles.container}>
        <Text style={styles.label}>Welcome to the Facebook SDK for React Native!</Text>
        <FBLoginButton />
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
  },
});

Some one tell why this issue persist and what can i do to resolve it.

like image 236
Khemraj Sharma Avatar asked May 23 '18 05:05

Khemraj Sharma


2 Answers

you have to change publishPermissions={["email"]} to readPermissions={["email"]}

like image 87
Mher Aghabalyan Avatar answered Oct 26 '22 02:10

Mher Aghabalyan


I changed publishPermissions={["email"]} to publishPermissions={["publish_actions"]}, and everything worked.

like image 1
Khemraj Sharma Avatar answered Oct 26 '22 03:10

Khemraj Sharma