Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offline Access not working #15

Open
jacobh0 opened this issue Oct 27, 2010 · 11 comments
Open

Offline Access not working #15

jacobh0 opened this issue Oct 27, 2010 · 11 comments
Labels

Comments

@jacobh0
Copy link
Contributor

jacobh0 commented Oct 27, 2010

I have offline_access as a permission to request, so I save the AccessToken from FB.AccessToken in my database after verifying the session is valid, but when I use this token from the DB in a call to newFB = new Facebook(accesstoken) and then proceed to do a call such as FacebookExtensions.PostToWall(newFB, "Message to my own wall!") I receive an invalid oauth token error.

@jacobh0
Copy link
Contributor Author

jacobh0 commented Oct 27, 2010

The token looks like this:

102072096507053|91ef4e3a32fbbc6bed1acffc-594308005|uH0gVxpWJFLFV0FC_pdLYGSDMV4

@prabirshrestha
Copy link
Owner

are you sure you have "publish_stream" access also?

you can see more of these extended permissions from http://developers.facebook.com/docs/authentication/permissions

@jacobh0
Copy link
Contributor Author

jacobh0 commented Oct 27, 2010

Yes I have publish_stream requested as well...

@prabirshrestha
Copy link
Owner

i just tried with the winforms sample and it works.

in btnLogin_Click i changed to the follwing code:

FacebookSettings fbSettings = new FacebookSettings
{
ApplicationKey = txtApiKey.Text,
DefaultApplicationPermissions =
new[] { "publish_stream", "offline_access" }
};

and in btnGetMyInfo_Click
Facebook fb = new Facebook(txtAccessToken.Text);
var id = fb.PostToWall("message to my own wall", null);

it works.
do you have the latest code? (actually it should be working even if you don't have the latest code. anyways could u download the latest code and try again.)

@jacobh0
Copy link
Contributor Author

jacobh0 commented Oct 28, 2010

I have the latest code, it worked when I called it with the expiration parameter set to 0:

fb.PostToWall("Message to my own wall!", 0)

It would not work without the 2nd parameter, I am using an iframe application.

@prabirshrestha
Copy link
Owner

there are some overloads to PostToWall.
the first parameter is the message: "message to my own wall"
but the second parameter is not expiration parameter, it is additional parameters which is a dictionary object. usually you would set it to null, but in case u r posting link,picture or something else then you might want to modify this custom parameter.

and some overloads contains the 3rd parameter called profileId, this is where you want to post to.
lets say u are user A and u want to post to user B's wall. then you would do
fb.PostToWall("message to B",null, user_id_of_b);

if you want to post to your own wall.
fb.PostToWall("message to myself",null,user_id_of_myself_that_is_A);
or
fb.PostToWall("message to myself",null,"me");
or shorthand
fb.PostToWall("message to myself",null); // by default posts to my wall

im wondering how you could even compile
fb.PostToWall("Message to my own wall!", 0)
coz 0 is not a IDictionary<string,string> so it would have a compile error. unless you mean null. and PostToWall has no overloads accepting expiration parameter.

@jacobh0
Copy link
Contributor Author

jacobh0 commented Oct 29, 2010

Sorry I meant fb = new Facebook(AccessToken, 0); not 0 for PostToWall, post to wall worked fine when I set the expiration when defining the new Facebook object.

@prabirshrestha
Copy link
Owner

that constructor was actually written to make it compatible with the original Android SDK written in Java which i ported from. even other methods such as SetAccessExpiresIn

for now could u use the another overloaded constructor that passes only access token. i will have a look at the one that passes the expires token.

thanks.

@prabirshrestha
Copy link
Owner

in Facebook.cs line number 123, there seems to be some problem when comparing date and time. that is making it fail when u specify the expires in. i will have a loot at it.

if (DateTime.Compare(FacebookUtils.Date.FromUnixTimestamp(AccessExpires), DateTime.UtcNow) > 0)

@jacobh0
Copy link
Contributor Author

jacobh0 commented Oct 30, 2010

It fails when you do NOT specify the expiration.

@prabirshrestha
Copy link
Owner

for now i have commented out the checking of IsSessionValid on PutObject extension method. (it is a temporary fix.)
could you try to download the latest source code and try it again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants