Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8392121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:26:19+00:00 2026-06-09T19:26:19+00:00

I’m having issues logging out using the Koala Gem, and wondering whether they’re related.

  • 0

I’m having issues logging out using the Koala Gem, and wondering whether they’re related.

Below is my Javascript code:

  <script>
    window.fbAsyncInit = function() {
      FB.init({
        appId      : '310521258992725', // App ID
        channelUrl : '//localhost:3000/channel', // Channel File
        status     : true, // check login status
        cookie     : true, // enable cookies to allow the server to access the session
        xfbml      : true  // parse XFBML
      });
      // Additional initialization code here
      // whenever the user logs in, we refresh the page

      FB.Event.subscribe('auth.login', function() {
        setTimeout('document.location.reload()',0);
      });

      FB.logout(function(response) {
        FB.Auth.setAuthResponse(null, 'unknown');
        setTimeout('document.location.reload()',0);
      });
    };


    // Load the SDK Asynchronously
    (function(d){
       var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
       if (d.getElementById(id)) {return;}
       js = d.createElement('script'); js.id = id; js.async = true;
       js.src = "//connect.facebook.net/en_US/all.js";
       ref.parentNode.insertBefore(js, ref);
     }(document));
  </script>

Below is my Facebook tag:

 <div id="fb-root"></div>

My logout code:

<a href="/" onclick="FB.logout();">Logout</a>

The login works perfectly and I can execute api calls no problem. However, after I logout, I get the following error:

OAuthException: Error validating access token: The session is invalid because the user logged out.  app/controllers/application_controller.rb:58: in 'fbookinvite_check'

Below is my fbookinvite_check code:

  def fbookinvite_check
    unless @facebook_cookies.nil?
      @access_token = @facebook_cookies["access_token"]
      @graph = Koala::Facebook::GraphAPI.new(@access_token)
      if !@graph.nil? == true
        @friends = @graph.get_object("/me/friends")
      end
    end
  end

The problem seems to be that the cookie is that the access token is invalidated, @graph is not showing as nil after the redirect. If I refresh, then the page loads no problem, but I get the error when I log out.

Perhaps there’s a way to catch the @graph.get_object error without shutting down the application?

Any suggestions would be greatly appreciated!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T19:26:21+00:00Added an answer on June 9, 2026 at 7:26 pm

    Yes, just wrap your fbookinvite_check in a begin/rescue where you rescue from OAuthException and then return something sane for your application.

    You answered your own question:

    Perhaps there’s a way to catch the @graph.get_object error without
    shutting down the application?

    Wrap your logic in a begin/rescue block like so:

    def fbookinvite_check
      begin
        unless @facebook_cookies.nil?
          @access_token = @facebook_cookies["access_token"]
          @graph = Koala::Facebook::GraphAPI.new(@access_token)
          if !@graph.nil? == true
            @friends = @graph.get_object("/me/friends")
          end
        end
      rescue OAuthException => ex
        # handle the exception if you need to, or just ignore it if thats ok too
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am reading a book about Javascript and jQuery and using one of the
We're building an app, our first using Rails 3, and we're having to build
I am using Paperclip to handle profile photo uploads in my app. They upload
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.