This project is read-only.

Ver 2.1 doesn't recognize new encrypted Access Token format

Sep 12, 2011 at 3:25 AM
Edited Sep 12, 2011 at 3:39 AM



I already downloaded ver 2.1 library for .NET 4.0, it doesn't work.

Here's what I have in my codes to get the Access Token.



string code = string.Empty;
string fbToken = string.Empty;
string pageUrl = "http://localhost:50103/NewFB2/FB2.aspx";
Response.Redirect("<myAppId>&redirect_uri=" + pageUrl + "&scope=email,publish_stream,offline_access");



string code = string.Empty;
string fbToken = string.Empty;
if (Request.QueryString["code"] != null)
  code = Request.QueryString["code"];
  string fullUri = "<myAppId>&redirect_uri=http://localhost:50103/NewFB2/FB2.aspx&client_secret=<myAppSecret>&code=" + code;
  HttpWebRequest fbRequest = WebRequest.Create(fullUri) as HttpWebRequest;
  fbRequest.Method = WebRequestMethods.Http.Post;
  HttpWebResponse fbResponse = fbRequest.GetResponse() as HttpWebResponse;
  StreamReader fbReader = new StreamReader(fbResponse.GetResponseStream());
  fbToken = fbReader.ReadToEnd();
  if (!string.IsNullOrEmpty(fbToken) && fbToken.StartsWith("access_token="))
    fbToken = fbToken.Substring(13);
  Facebook_Graph_Toolkit.GraphApi.Api fbapi = new Facebook_Graph_Toolkit.GraphApi.Api(fbToken);
  string token = fbapi.AccessToken; // exception caught here!!!
  Response.Write("<br>token: " + token + "<BR>");
catch (Exception ex)
  Response.Write("exception caught: " + ex.Message);

Token format I got is like the below



I will get the Invalid Access Token exception inside the try/catch block. Any idea why?!?


EDIT: I tested the .NET 3.5 version, it worked. Please fix the .NET 4.0 library.

Sep 15, 2011 at 7:13 PM

I cannot reproduce your error. If you check the dll versions of the libraries then you'll see they both have the same version number, which means they're generated with the exact same code. Moreover the canvas app example is also using .Net 4.0, and so far no problem has occured.

Sep 29, 2011 at 9:49 PM
Edited Sep 29, 2011 at 9:50 PM


I have the same problem (version 2.1 .net 4). I always get the same token for any combination of permissions... So I can not get data with permission... For my parameters the tooken is always 


How can it be so? 




Partial Class _Default

    Inherits SocialPage

    Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
        If Api Is Nothing Then
        End If
    End Sub

    Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load

            If Api IsNot Nothing Then

                Dim U As New Facebook_Graph_Toolkit.GraphApi.User("me",Api.AccessToken)

                Response.Write("Birthday: " & U.Birthday)

                Response.Write("API NULL")

            End If
        Catch ex As Exception

        End Try
    End Sub

    Protected Sub Page_PreInit(sender As Object, e As System.EventArgs) Handles Me.PreInit
        ExtendedPermissions = "publish_stream,user_birthday,user_photos,email,user_photo_video_tags,user_likes"
    End Sub

End Class