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 7678089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:33:54+00:00 2026-05-31T17:33:54+00:00

I am stuck with facebook authentication for the last 5 hours now and I

  • 0

I am stuck with facebook authentication for the last 5 hours now and I don’t have a lot of thoughts on my mind why I am getting error: 400 bad request.
I found one sample app on the web where user gets authorized and then proceeds with the app, I am running the same app locally and I am able to run it and get the access token correctly.
Here is the method to get the token:

 /// <summary>
        /// Get the authorisation token
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        public Dictionary<string, string> GetAccessToken(string code, string scope,string  redirectUrl)
        {
            Dictionary<string, string> tokens = new Dictionary<string, string>();
            string clientId = FacebookContext.Current.AppId;            
            string clientSecret = FacebookContext.Current.AppSecret;
            string url = string.Format("https://graph.facebook.com/oauth/access_token?client_id={0}&redirect_uri={1}&client_secret={2}&code={3}&scope={4}",
                            clientId, redirectUrl, clientSecret, code, scope);
            HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
            using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
            {
                StreamReader reader = new StreamReader(response.GetResponseStream());
                string retVal = reader.ReadToEnd();

                foreach (string token in retVal.Split('&'))
                {
                    tokens.Add(token.Substring(0, token.IndexOf("=")),
                        token.Substring(token.IndexOf("=") + 1, token.Length - token.IndexOf("=") - 1));
                }                
            }
            return tokens;
        }

The problem happens when the response tries to get the response from the request object:

using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)

With the sample app I don’t have any problems, but in the app I am trying to use the code I am getting 400 bad request error.
The url parameter looks pretty much the same and that’s why I don’t have idea what I am doing wrong.
Here is the sample app format of the url:

https://graph.facebook.com/oauth/access_token?client_id=MY_APP_ID&redirect_uri=http://localhost:5000/fbregcallback.aspx&client_secret=982161272e8adc3af17952dc0f70b67e&code=AQBSvKfdc3ynTWeJTVSq7Y2JRV52YNCHPV5nAluxVf3_Ger68NJZeWScbKg1ttMfVOuXrOTfbvgq6o_bXIemnlx2yH-eu2vDvs-94EDEPxHFPUTQ4UjnSgxKAZjs6h-APxqHrRz5gvlafYb89uIoGhBuu-sIPrvIThBK-BmFRuytrj2fHYSU9y_xbFIjAYNUw_U&scope=user_birthday,publish_stream,create_event,user_photos

My app url format:

https://graph.facebook.com/oauth/access_token?client_id=MY_APP_ID&redirect_uri=http://localhost:47736/Default.aspx&client_secret=982161272e8adc3af17952dc0f70b67e&code=AQBd_IYcBLy-UfV68PDH8gWFOud5eLzVt8ZukSVfo35qSLw7jn5yrpw-zqr4WhVigv0G1tVtEVIj2fnvBAzmWU3SlOtZgCC-0P1sBRQ999JP60Qe4s0UT1c0Z1cupMW8qNdDfuBhzxty9581gTISPq9xYF1SEifX60kDUc1bd7FuUGsGyGBgtfzO8PdNZoGrq6Y&scope=user_birthday,publish_stream,create_event,user_photos

Every advice will be welcomed because this problem really comes on my nerves at this moment.
Thanks a lot, Laziale

  • 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-05-31T17:33:55+00:00Added an answer on May 31, 2026 at 5:33 pm

    Facebook tends to not like localhost urls. You can create an entry for a fake domain in your hosts file (e.g fbdev.com) and set that domain (with port) as your application URL and domain in the basic settings for your app in the developers console.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created topbar like Facebook app now I'm stuck I want to create
My facebook app iframe height is stuck at 800px. I have it set at
I am developing a facebook app and I seem to have got stuck on
I am a beginner to Facebook app development. I am stuck with an authentication
I have been stuck with this problem for a while now, and I just
I have a Facebook PHP SDK APP in development phase and i'm stuck on
I have searched for info on the is misconfigured for Facebook login error message
I don't know when it happened but I'm getting this error NoMethodError (undefined method
I'm new to the Facebook Graph, but I appear to be stuck. I have
i'm stuck at this facebook application, not knowing how do i go ahead. for

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.