Reputation: 143
So i'm trying to wrap my head around the Facebook API for Unity, and I think i'm starting to get the hang of it...until this
FB.Login ("public_profile, user_photos, email", AuthCallBack);
so as you can see I obviously ask for the email permission, yet when I try to call it in Unity
Dictionary<string, string> emailDict = new Dictionary<string, string>(){{"email", ""}};
FB.API( "me?fields=email", Facebook.HttpMethod.GET, FBGetEmail, emailDict);
print ("emailDict " + emailDict.Keys);
This only yields me my userid. I did some further digging into the Graph Explorer with the same newly generated access token which I got from the app which revealed the following
The field 'email' is only accessible on the User object after the user grants the 'email' permission.
{"id": "952814180948",}
so my question is... does anyone know//can anyone see what i'm doing wrong to not be able to get the email permission? Since the problem is obviously in the initial request when when the access token is generated. I know the permissions are working as I'm able to pull and use my profile pic..just not the email :'(
Upvotes: 1
Views: 4069
Reputation: 11
25-June-2024
In Meta for Developers App Dashboard
Click Use Case > Authentication and account creation > Customize
Add Email in Permissions Section
Upvotes: 1
Reputation: 143
So I figured it out!!! The answer is nestled in a single line in the facebook docs. Basically, when using the authentication tokens in Unity's editor mode, It allows you go "get token" But this generated token has just some default permissions.
You need to actually go to the graph explorer, and at the top set your app to YOUR APP ( it wasnt clear, I thought that it made you go to your app page NOT generate access tokens for your app).
Once I did that, I was able to generate new access tokens with the permissions I wanted by using the Get Access Token Button on the graph explorer page.
Oish! Two whole days just to figure that out.
Upvotes: 6