Posts tagged with facebook-login

I am trying to implement Facebook login for my application. It was working well in development mode, but when I try to switch to live mode I see this message:

Feature Unavailable

Facebook Login is currently unavailable for this app, since we are updating additional details for this app. Please try again later.

here is the exact error I get

I do not have any required actions in developer console.

I have searched for an answer, I have already set advanced access to email and public profile, and I got advanced access to other permissions as well. Business verification is complete and I have verified my Business as a tech provider as well.

Here is the code that handles the Facebook login (I am using Django framework):

def facebook_login(request):     facebook_auth_url = "https://www.facebook.com/v21.0/dialog/oauth"     if "test" in request.get_full_path():        redirect_uri = request.build_absolute_uri('/test/home/facebook_login/facebook_callback/')        redirect_uri = "http://localhost:8000/home/facebook_login/facebook_callback/"     else:         redirect_uri = request.build_absolute_uri('/home/facebook_login/facebook_callback/')     scopes = "pages_show_list,business_management,read_insights,ads_read,pages_read_engagement,ads_management"          state = generate_state()     request.session['oauth_state'] = state          params = {         'client_id': settings.META_APP_ID,         'redirect_uri': redirect_uri,         'scope': scopes,         'response_type': 'code',         'state': state,     }     auth_url = f"{facebook_auth_url}?{urlencode(params)}"     return JsonResponse({'authorization_url': auth_url}) def facebook_callback(request):     error = request.GET.get('error')     if error == 'access_denied':         prefix = 'test/' if os.getenv('PROD') == 'blue' else ''         cancel_redirect_url = (             "http://localhost/" + prefix + "#/home/connections"              if os.getenv('DEVELOPMENT') == 'True'              else "https://platform.webalyze.ai/" + prefix + "#/home/connections"         )         return redirect(cancel_redirect_url)          state = request.GET.get('state')     if state != request.session.pop('oauth_state', None):         return JsonResponse({'error': 'Invalid state parameter'}, status=400)     code = request.GET.get('code')     if not code:         return JsonResponse({'error': 'No code provided'}, status=400)     token_exchange_url = "https://graph.facebook.com/v21.0/oauth/access_token"     redirect_uri = request.build_absolute_uri(request.path)     print('REDIRECT (facebook_callback):', redirect_uri)     params = {         'client_id': settings.META_APP_ID,         'redirect_uri': redirect_uri,         'client_secret': settings.META_APP_SECRET,         'code': code,     }     response = requests.get(token_exchange_url, params=params)     data = response.json()     if 'access_token' in data:         access_token = data['access_token']         saveMetaTokenToDatabase(request.user, access_token)         prefix = 'test/' if os.getenv('PROD') == 'blue' else ''         if os.getenv('DEVELOPMENT') == 'True':             return redirect("http://localhost/" + prefix + "#/home/connections")         else:             return redirect("https://platform.webalyze.ai/" + prefix +"#/home/connections")     else:         return JsonResponse({'error': 'Failed to obtain access token'}, status=400) 

What am I missing so I can do this in live mode?

i want to give partner access of business assets to someone via Facebook api, but i have no idea how it can be done.

I tried to use page-id/assigned_users API to assign a page to the user but that also didn't worked, sometimes i got the error, that app-scoped id is invalid and other time i got error: "there is not business linked with this id".

I did some research over chatgpt, and what i got to know is, firstly i need to add the user to business manager and only then i can use above api. But i am not sure if the chatgpt answer is reliable or not.

I have read facebook documentation, but its very confusing !!!

I am new to facebook graph api, so any small help will be really appreciated.

I implemented successfully the code to make a request to the Facebook GraphRequest by using the the following code:

GraphRequest request = GraphRequest.newMeRequest(loginResult.getAccessToken(), new GraphRequest.GraphJSONObjectCallback() {   ... } 

In some documentation I found the code below to retrieve values:

Bundle parameters = new Bundle(); parameters.putString("fields","name,email"); request.setParameters(parameters); request.executeAsync(); 

I want to use System.out.println() to print out name and email of the person who logged in successfully with Facebook to my Android app. How can I invoke request to print out those values? Thank you.

UPDATE 1:

I suspect I might be experiencing the same problem reported at Facebook Integration Android: onCompleted(GraphJSONObjectCallback) block not executing: onCompleted(GraphJSONObjectCallback) block not executing

See more context of my code:

private void handleFacebookAccessToken(LoginResult loginResult) {   GraphRequest request = GraphRequest.newMeRequest(loginResult.getAccessToken(), new GraphRequest.GraphJSONObjectCallback() {     @Override     public void onCompleted(@Nullable JSONObject jsonObject, @Nullable GraphResponse graphResponse) {       //Access the response here and retrieve the information you want and print it out       String rawResponse = graphResponse.getRawResponse();       System.out.println("rawResponse: "+rawResponse);     });     Bundle parameters = new Bundle();     parameters.putString("fields","name,email");     request.setParameters(parameters);     request.executeAsync(); } 

I was expecting the following line to print out the response to the request, but I do not see anything printed out:

System.out.println("rawResponse: "+rawResponse); 

I'm integrating Facebook Business Login using the Facebook JS SDK. Despite following many tutorials and the official guide, I've encountered a persistent issue over the past few days. I believe this might be an edge case specific to my setup.

The problem

Both FB.getLoginStatus() and FB.login() call functions return below response.

{authResponse: null, status: 'unknown'}  

I'm certain I've logged into Facebook and it should show "connected" instead. The issue is that callback functions are being triggered before Facebook returns the response. For example, when FB.login() opens the login dialog, the console shows the callback response before login completion. Additionally, after completing the login, the callback function is no longer called. Here is a screenshot:

Here is the source code

(I just copy-pasted from Facebook Offical Guide)

    <!DOCTYPE html> <html> <head> <title>Facebook Login JavaScript Example</title> <meta charset="UTF-8"> </head> <body> <script>   function statusChangeCallback(response) {  // Called with the results from FB.getLoginStatus().     console.log('statusChangeCallback');     console.log(response);                   // The current login status of the person.     if (response.status === 'connected') {   // Logged into your webpage and Facebook.       testAPI();       } else {                                 // Not logged into your webpage or we are unable to tell.       console.log( 'Please log ' +         'into this webpage.');         FB.login((response) => {           console.log(response)         },{             "config_id":{{FACEBOOK_CONFIG_ID}}         })     }   }   function checkLoginState() {               // Called when a person is finished with the Login Button.     FB.getLoginStatus(function(response) {   // See the onlogin handler       statusChangeCallback(response);     });   }   window.fbAsyncInit = function() {     FB.init({       appId      : '{{FACEBOOK_APP_ID}}',       cookie     : true,                     // Enable cookies to allow the server to access the session.       xfbml      : true,                     // Parse social plugins on this webpage.       version    : 'v20.0'           // Use this Graph API version for this call.     });     FB.getLoginStatus(function(response) {   // Called after the JS SDK has been initialized.       statusChangeCallback(response);        // Returns the login status.     });   };     function testAPI() {                      // Testing Graph API after login.  See statusChangeCallback() for when this call is made.     console.log('Welcome!  Fetching your information.... ');     FB.api('/me', function(response) {       console.log('Successful login for: ' + response.name);       document.getElementById('status').innerHTML =         'Thanks for logging in, ' + response.name + '!';     });   } </script> <!-- The JS SDK Login Button --> <fb:login-button config_id="{{FACEBOOK_CONFIG_ID}}" onlogin="checkLoginState();"> </fb:login-button> <div id="status"> </div> <!-- Load the JS SDK asynchronously --> <script async defer crossorigin="anonymous" src="https://connect.facebook.net/en_US/sdk.js"></script> </body> </html> 

My Environment

I use Facebook Business Login so I can ask my clients permission to manage their pages. I've configured User Access Token configuration and included my Config ID in both login button and in FB.login() function. My Business is verified. I'm testing this in localhost. (I have local ssl and I use HTTPS. Also I've deployed this in my live web app where i have https as well and facing the same problem). My App is in Live mode.

Below are some screenshots from my app configs. I'm trying to give lot of details as I beleive this might be specific to my app configurations.

What I've Tried

  1. I've tried both FB.login() and Facebook login Button. (with facebook login button the onlogin callback function never getting called)

  2. I've deleted ALL my cookies and files

  3. I've deployed this in Live web app

UPDATE

There is a fblo_<app_id> cookie, which my research indicates is a Facebook logout cookie, defaulting to a value of "y". When I manually delete this cookie, the status changes to "connected" (sometimes this works and sometimes not.). However, it's not feasible to ask my clients to perform this action on their end. Additionally, the callback functions are still being triggered before the login (reconnect) process is complete. So maybe there might be an issue related to cookies or sessions.