Hi, I was running RN 0.19 up until the other day, when I moved to 0.23. I had relied on the logInWithPermissions function from require('NativeModules').FBLoginManager; in order to get the accessToken for a user so I can authenticate in my app... but it seems that the new version doesn't support getting the access token. Instead, I get:
{
declinedPermissions: [],
grantedPermissions: [ 'user_friends', 'email' ],
isCancelled: false
}
Any help would be much appreciated.
EDIT: I am running on Android.
Having the same exact issue. Any luck?
Still nothing... will try to investigate more today. But nothing in the code has jumped out at me.
import FBSDK, {
LoginManager,
AccessToken
} from 'react-native-fbsdk'
// Login...
AccessToken.getCurrentAccessToken().then((accessToken) => console.log(accessToken))
I'll give that a go tomorrow, thanks a lot!
Quite embarrassed that I didn't spot the FBAccessToken file... too many late nights :X
When I console.log(accessToken) it says object Object. When I console.log(accessToken.token) it logs undefined. Any suggestions on how to get the token as string?
Thanks in advance!
console.log(accessToken.accessToken)
Just want to add this in here for anyone using the LoginButton
You'd do something like this:
<LoginButton
publishPermissions={["publish_actions",]}
onLoginFinished={
(error, result) => {
if (error) {
alert("login has error: " + result.error);
} else if (result.isCancelled) {
alert("login is cancelled.");
} else {
// This prints out the access token object (includes expiration time and etc...)
AccessToken.getCurrentAccessToken().then((accessToken) => console.log(accessToken))
}
}
}
onLogoutFinished={() => alert("logout.")} />
Most helpful comment