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

  • SEARCH
  • Home
  • 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 8849485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:39:57+00:00 2026-06-14T12:39:57+00:00

I’m building an application that allows users to post message to their facebook from

  • 0

I’m building an application that allows users to post message to their facebook from the application. To problem I’m having that I don’t know how to get the user access_token for the publish_stream permission.

This is what I’ve got so far:

        var fb = new FacebookClient();
        dynamic result = fb.GetLoginUrl(new
        {
            client_id = AppID,
            client_secret = AppSecret,
            grant_type = "client_credentials",
            scope = "publish_stream",
            state = "http://localhost:17578/Facebook.aspx",
            redirect_uri = "http://localhost:17578/Facebook.aspx"
        });

That works fine and it returns a ‘code’ in the querystring. However, I’m not sure what to do with that code.
The ‘old’ Facebook C# sdk contained the FacebookOAuthClient class which had the ExchangeCodeForAccessToken() method, but I don’t know what the replacement of this static method is in the new SDK.

So the question really is: How to exchange the code that is returned for an access_token?

  • 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-14T12:39:58+00:00Added an answer on June 14, 2026 at 12:39 pm

    After you get the code query string parameter you must make a call to the Facebook Graph API to get the access token.

    https://developers.facebook.com/docs/howtos/login/server-side-login/

    FacebookClient client = new FacebookClient();
    dynamic result = client.Get("oauth/access_token", new { client_id = Settings.Social_Facebook_App_Id, client_secret = Settings.Social_Facebook_Secret_Key, code = Request.QueryString["code"], redirect_uri = Settings.Social_Facebook_Login_Redirect_URI });
    if (result.error == null)
    {
        Session["AccessToken"] = client.AccessToken = result.access_token;
        dynamic user = client.Get("me", new { fields = "name,username,email" });
        string userName = user.username;
    
        mu = Membership.GetUser(userName);
        if (mu == null)  // Register
        {
            RegisterModel rm = new RegisterModel();
            rm.Email = user.email;
            rm.UserName = userName;
            return View("Register", rm);
        }
        else
        {
            FormsAuthentication.SetAuthCookie(userName, true);
            return RedirectToAction(MVC.Home.Index());
        }
    }
    
    • 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
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
Does anyone know how can I replace this 2 symbol below from the string
I am currently running into a problem where an element is coming back from
I'm trying to create an if statement in PHP that prevents a single post
Let's say I'm outputting a post title and in our database, it's Hello Y’all
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.