Ver 2.1 doesn't recognize new encrypted Access Token format

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

Hi,

 

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.

FB.aspx.cs

 

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

FB2.aspx.cs

 

string code = string.Empty;
string fbToken = string.Empty;
if (Request.QueryString["code"] != null)
{
  code = Request.QueryString["code"];
  string fullUri = "https://graph.facebook.com/oauth/access_token?client_id=<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();
  fbResponse.Close();
  if (!string.IsNullOrEmpty(fbToken) && fbToken.StartsWith("access_token="))
    fbToken = fbToken.Substring(13);
}
try
{
  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

AAABddZAETAbYBAE40iFbHxLJecpt0QAkmQPSdwUa2ZC8zNFCyvADXgRmkFHeHEJNpZC989H9ANuUivALGyCbvvtcZBJH1cYPZCrcZBdHKYPgZDZD

 

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.

Coordinator
Sep 15, 2011 at 6: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 8:49 PM
Edited Sep 29, 2011 at 8:50 PM

Hi!

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 

AAADcPXVOGzkBAOCZAULkmatqmhqWuiLDigi0TasuLIp0nUzzkBdxLlEERZAdkIeItOAuMG9TVC0NeORus6DtN91c0ZC3nRH4xbOH0nRWQZDZD

How can it be so? 

 

code

 

Partial Class _Default


    Inherits SocialPage

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

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

            If Api IsNot Nothing Then
                             Response.Write(Api.AccessToken)

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

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


            Else
                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