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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T15:46:48+00:00 2026-05-19T15:46:48+00:00

I am trying to get a sample project to work with dotnetopenauth and facebook.

  • 0

I am trying to get a sample project to work with dotnetopenauth and facebook.

I have this code

namespace OAuthClient
{
    using System;
    using System.Configuration;
    using System.Net;
    using System.Web;
    using DotNetOpenAuth.ApplicationBlock;
    using DotNetOpenAuth.ApplicationBlock.Facebook;
    using DotNetOpenAuth.OAuth2;

public partial class Facebook : System.Web.UI.Page
{
    private static readonly FacebookClient client = new FacebookClient
    {
        ClientIdentifier = ConfigurationManager.AppSettings["facebookAppID"],
        ClientSecret = ConfigurationManager.AppSettings["facebookAppSecret"],
    };

    protected void Page_Load(object sender, EventArgs e)
    {

        IAuthorizationState authorization = client.ProcessUserAuthorization();

        if (authorization == null)
        {
            var authorizationState = new AuthorizationState()
            {
                Callback = new Uri(Request.Url, "http://localhost:3000/Facebook.aspx/")
            };
            client.PrepareRequestUserAuthorization(authorizationState).Send();
        }
        else
        {
            var request = WebRequest.Create("https://graph.facebook.com/me?access_token=" + Uri.EscapeDataString(authorization.AccessToken));
            using (var response = request.GetResponse())
            {
                using (var responseStream = response.GetResponseStream())
                {
                    var graph = FacebookGraph.Deserialize(responseStream);
                    this.nameLabel.Text = HttpUtility.HtmlEncode(graph.Name);
                }
            }
        }
    }
}

}

So I make request first to facebook and that works nice and fine. I then get a response back from them and it goes into the else statement.

However I run into this error( happens on var graph = FacebookGraph.Deserialize(responseStream) )

Server Error in '/' Application.
Value was either too large or too small for an Int32.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.OverflowException: Value was either too large or too small for an Int32.

Source Error:

Line 49:            }
Line 50: 
Line 51:            return (FacebookGraph)jsonSerializer.ReadObject(jsonStream);
Line 52:        }
Line 53:    }


Source File: C:\Users\user\Downloads\DotNetOpenAuth-3.5.0.10357\DotNetOpenAuth-3.5.0.10357\Samples\DotNetOpenAuth.ApplicationBlock\Facebook\FacebookGraph.cs    Line: 51

Stack Trace:

[OverflowException: Value was either too large or too small for an Int32.]
   System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +7471379
   System.Runtime.Serialization.Json.XmlJsonReader.ParseInt(String value, NumberStyles style) +68

[XmlException: The value '100000325104290' cannot be parsed as the type 'Int32'.]
   System.Runtime.Serialization.Json.XmlJsonReader.ParseInt(String value, NumberStyles style) +259
   System.Runtime.Serialization.Json.XmlJsonReader.ReadContentAsInt() +22
   System.Xml.XmlDictionaryReader.ReadElementContentAsInt() +62
   System.Runtime.Serialization.XmlReaderDelegator.ReadElementContentAsInt() +26
   ReadFacebookGraphFromJson(XmlReaderDelegator , XmlObjectSerializerReadContextComplexJson , XmlDictionaryString , XmlDictionaryString[] ) +628
   System.Runtime.Serialization.Json.JsonClassDataContract.ReadJsonValueCore(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context) +58
   System.Runtime.Serialization.Json.JsonDataContract.ReadJsonValue(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context) +31
   System.Runtime.Serialization.Json.XmlObjectSerializerReadContextComplexJson.ReadDataContractValue(DataContract dataContract, XmlReaderDelegator reader) +25
   System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, DataContract& dataContract) +128
   System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator xmlReader, Type declaredType, DataContract dataContract, String name, String ns) +39
   System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserialize(XmlReaderDelegator xmlReader, Type declaredType, DataContract dataContract, String name, String ns) +32
   System.Runtime.Serialization.Json.DataContractJsonSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName) +1048152
   System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName) +98

[SerializationException: There was an error deserializing the object of type DotNetOpenAuth.ApplicationBlock.Facebook.FacebookGraph. The value '100000325104290' cannot be parsed as the type 'Int32'.]
   System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName) +496
   System.Runtime.Serialization.Json.DataContractJsonSerializer.ReadObject(XmlDictionaryReader reader) +43
   System.Runtime.Serialization.Json.DataContractJsonSerializer.ReadObject(Stream stream) +67
   DotNetOpenAuth.ApplicationBlock.Facebook.FacebookGraph.Deserialize(Stream jsonStream) in C:\Users\user\Downloads\DotNetOpenAuth-3.5.0.10357\DotNetOpenAuth-3.5.0.10357\Samples\DotNetOpenAuth.ApplicationBlock\Facebook\FacebookGraph.cs:51
   OAuthClient.Facebook.Page_Load(Object sender, EventArgs e) in C:\Users\user\Downloads\DotNetOpenAuth-3.5.0.10357\DotNetOpenAuth-3.5.0.10357\Samples\OAuthClient\Facebook.aspx.cs:39
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +50
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627


Version Information: Microsoft .NET Framework Version:2.0.50727.4952; ASP.NET Version:2.0.50727.4955 

So this class gets called

//-----------------------------------------------------------------------
// <copyright file="FacebookGraph.cs" company="Andrew Arnott">
//     Copyright (c) Andrew Arnott. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace DotNetOpenAuth.ApplicationBlock.Facebook {
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Runtime.Serialization;
    using System.Runtime.Serialization.Json;
    using System.Text;

    [DataContract]
    public class FacebookGraph {
        private static DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(FacebookGraph));

        [DataMember(Name = "id")]
        public int Id { get; set; }

        [DataMember(Name = "name")]
        public string Name { get; set; }

        [DataMember(Name = "first_name")]
        public string FirstName { get; set; }

        [DataMember(Name = "last_name")]
        public string LastName { get; set; }

        [DataMember(Name = "link")]
        public Uri Link { get; set; }

        [DataMember(Name = "birthday")]
        public string Birthday { get; set; }

        public static FacebookGraph Deserialize(string json) {
            if (String.IsNullOrEmpty(json)) {
                throw new ArgumentNullException("json");
            }

            return Deserialize(new MemoryStream(Encoding.UTF8.GetBytes(json)));
        }

        public static FacebookGraph Deserialize(Stream jsonStream) {
            if (jsonStream == null) {
                throw new ArgumentNullException("jsonStream");
            }

            return (FacebookGraph)jsonSerializer.ReadObject(jsonStream);
        }
    }
}

Has something changed with the AccessToken? Are they bigger now?

I know this sample is using an older version than the current version of dotnetopenauth but the current version does not include facebook

dotnetopenauth CTP

  • 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-19T15:46:49+00:00Added an answer on May 19, 2026 at 3:46 pm

    Yes, the Facebook id should be Int64 instead of Int32 now.

    Take a look at this change

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

Sidebar

Related Questions

I'm trying to get this sample for AJAX to WCF working, with the following
I'm trying get values from a GridView using the following code: foreach (GridViewRow row
I'm trying to get this simple PowerShell script working, but I think something is
I have been trying to get more in to TDD. Currently keeping it simple
Trying to get my css / C# functions to look like this: body {
Trying to get this example working from http://www.munna.shatkotha.com/blog/post/2008/10/26/Light-box-effect-with-WPF.aspx However, I can't seem to get
I am trying to get simple jQuery to execute on my Content page with
I'm trying to get a simple search form working in my RoR site. I've
I am trying to get a simple demo started with ActiveMQ that will demonstrate
Trying to get an ASP application deployed; it worked for a while but then

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.