Search code examples
facebooknativescriptaccess-tokenkinvey

too short FB accessToken in Kinvey _socialIdentity using kinvey-nativescript-sdk


I have working log-in process with Facebook using Kinvey MIC in my NativeScript app. I am able to log-in into the Kinvey and _socialIdentity record is successfully created. Due to the fact that I need to know also user's email registered with FB account (that is not sent in basic User response from FB), I need to query FB Graph API for that.

https://graph.facebook.com/v3.2/me?fields=id,name,email&access_token= + accessToken

If I use a accessToken stored in Kinvey's _socialIdentity, FB returns: "error": { JS: "message": "Invalid OAuth access token.", JS: "type": "OAuthException", JS: "code": 190, JS: }

If I use accessToken generated by FB developers tool and hardcode it into my NS code, everything works well - I receive all requested info.

The difference I found is length of the accessToken: accessToken stored in Kinvey has 40 characters but the one generated by FB tools has 247 characters.

Could somebody explain why FB accessToken in Kinvey's _socialIdentity is short/impossible for further use or how to get a valid accessToken using kinvey-nativescript-sdk? Also if somebody achieved to get an user's contact email from FB account using kinvey-nativescript-sdk.

Thank you


Solution

  • Can you try adding client_token to the Allowed Attributes section of the Mobile Identity Connect service configuration?

    That will create a new attribute on the kinveyAuth object (that is contained in the _socialIdentity attribute of the User entity), which will hold the access token that you are talking about.

    Can you try that, and let me know if it works?

    Edit: You can also try adding idp_access_token to the Allowed Attributes section. That will directly create an attribute to the kinveyAuth entity, which will hold only the needed token.