Facebook SDK 5.1 Login Access Token

Hi all,

I just recently started using the facebook SDK, I’ve followed the guide at facebook site https://developers.facebook.com/docs/games/unity/unity-tutorial, and I have written a very simplified code just to test logging into facebook, as below

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using Facebook.MiniJSON;
using System;

public class FBLoginControl : MonoBehaviour {

    public Rect LoginButtonRect;

	// Use this for initialization
	void Awake () {
        enabled = false;    //Stop rendering GUI until FB SDK is initialized
        FB.Init(SetInit, OnHideUnity);
	}
	
	// Update is called once per frame
	void Update () {
	
	}

    void OnGUI()
    {
        if (!FB.IsLoggedIn)
        {
            if (GUI.Button(LoginButtonRect, "Login Facebook"))
            {
                FB.Login("email,publish_actions", LoginCallback);
            }
        }
    }

    /// <summary>
    /// Used as a delegate when initialization is completed
    /// </summary>
    private void SetInit()
    {
        print("SetInit");
        //Game initialization here

        enabled = true; // "enabled" is a property inherited from MsonoBehaviour                  

        //****End of game init****

        if (FB.IsLoggedIn)
        {
            print("Already logged in");
            OnLoggedIn();
        }
    }

    /// <summary>
    /// Called when user has completed a login action.
    /// </summary>
    /// <param name="result"></param>
    void LoginCallback(FBResult result)
    {
        print("LoginCallback");

        if (FB.IsLoggedIn)
        {
            OnLoggedIn();
        }
    }   

    /// <summary>
    /// Called when the Facebook canvas needs to hid or show the game
    /// </summary>
    /// <param name="isGameShown"></param>
    private void OnHideUnity(bool isGameShown)
    {
        print("OnHideUnity");
        if (!isGameShown)
        {
            // pause the game - we will need to hide                                             
            Time.timeScale = 0;
        }
        else
        {
            // start the game back up - we're getting focus again                                
            Time.timeScale = 1;
        }
    }

    void OnLoggedIn()
    {
        print("Logged in. ID: " + FB.UserId);

        // Reqest player info and profile picture                                                                           
        //FB.API("/me?fields=id,first_name,friends.limit(100).fields(first_name,id)", Facebook.HttpMethod.GET, APICallback);
        //LoadPicture(Util.GetPictureURL("me", 128, 128), MyPictureCallback);
    }

    void APICallback(FBResult result)
    {
        print("APICallback");
        if (result.Error != null)
        {
            print(result.Error);
            // Let's just try again                                                                                                
            FB.API("/me?fields=id,first_name,friends.limit(100).fields(first_name,id)", Facebook.HttpMethod.GET, APICallback);
            return;
        }

        //profile = Util.DeserializeJSONProfile(result.Text);
        //GameStateManager.Username = profile["first_name"];
        //friends = Util.DeserializeJSONFriends(result.Text);
    }

    void MyPictureCallback(Texture texture)
    {
        print("MyPictureCallback");

        if (texture == null)
        {
            // Let's just try again
            //LoadPicture(Util.GetPictureURL("me", 128, 128), MyPictureCallback);
            return;
        }
        //GameStateManager.UserTexture = texture;
    }    
}

However, I expected when clicking the “Login” button, it shall prompt me for email and password or such information, but instead it asks me access token. Why is it? The guideline does not say anything about access token, but I have tried reading about token here: Access Token Guide - Facebook Login - Documentation - Meta for Developers

But still, I couldn’t find a way how to make my login using email/pw instead of inputting the token. Please help and thanks in advance! :smiley:

You are in debug mode thats why its asking for access token. when prompt window show up;

  • press “Find Access Token”
  • copy “User Token” under your app name. if its not click link and generate one.
  • past token to prompt window.

it will ask user password or permission when you test your app on native enviroment.