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

How do we logout from facebook and clear access tokens as well as cookies? #20

Closed
sylarific opened this issue Nov 22, 2010 · 11 comments
Closed

Comments

@sylarific
Copy link

When I login to the facebook app on the windows phone 7 emulator, it grants an access token, and then I can post to wall and stuff..but I cant logout then..
Is there any help for this available??
I am using the graph API

@prabirshrestha
Copy link
Owner

im not sure if i quite understood ur question.

do u want to logout and post as another user without exiting the app?

if so u will have to use a bit of javascript to do it.
host a browser control. navigate to a html page of your own. you should write a javsacript code to logout of facebook using the javscript facebook sdk.
after you logout, you will need to redirect to your login page and get the access token as you did before.

another way is to logout using the facebook redirect but it is not documented.

please see this on how to do it. http://stackoverflow.com/questions/2764436/facebook-oauth-logout

please feel free to ask if you have any more problems.

@sylarific
Copy link
Author

But, Can we use facebook javascript sdk on windows phone 7 application?
i'm not quite sure how that would work..

i'm trying to read the link you gave..it is exactly the same prob i have, except that I cant logout of that wp7 app.. If another user tries to login, the previous user's profile still comes..

Also, can we use the Publish_Stream window by any chance ?
because when i click on post to wall..it just posts..it doesnt show the pop up window like there is for javascript sdk ( FB.Connect.streamPublish() )

@prabirshrestha
Copy link
Owner

how do u get the facebook access token for windows phone?

u will need to use WebBrowser control inside of your app. http://msdn.microsoft.com/en-us/library/ff431797(VS.92).aspx

you will need to only use JsSDK for for getting access token. after that you use Facebook# library and you can forget the webbrowser control after that.
the only way to get access token is by logging inside facebook.com website. thats how the desktop apps or any other silvlierght apps works. the only thing is it actually doesnt have a browser window so it looks as if it is a native app. this is same for whether you are developing on iphone or android too.
try looking at winforms sample app that is provided on how to login to facebook. you can use similar concept for windows phone.

@sylarific
Copy link
Author

i use the graph oauth facebook url for getting the access token...

the whole project is done on visual studio express..i am not sure how to use jsSDK with c#.. could you give me a windows phone example as to how we can use jsSDK with wp7 application.

thanks :)

@prabirshrestha
Copy link
Owner

first of all create a asp.net website. lets say www.fb.com/logout.aspx

put this code and change neccessarily, i have comented it.
https://gist.github.com/711352
or you could read the javascript sdk. http://developers.facebook.com/docs/reference/javascript/
(this part of ur app is non-windows phone app, its a normal asp.net website hosted in some webserver)

so then use WebBrowser control to navigate to this url.

incase you can't host the website, you mite well as trying navigating to
http://m.facebook.com/logout.php?confirm=1&next=http://yourdomain.com

replace yourdomain.com with the value from FacebookContext.Settings.FacebookAuthorizeUrl

it basically logs you out of facebook and then again asks you to login.

@sylarific
Copy link
Author

ok, now i tried the navigating the URL using WB to http://m.facebook.com/logout.php?confirm=1

i am not able to logout..it doesn't perform any action for this..

what is the yourdomain value???

getting confused regarding that..

@sylarific
Copy link
Author

get this error if I try to execute what you said:

WindowsPhoneApplication1.dll!WindowsPhoneApplication1.App.RootFrame_NavigationFailed(object sender, System.Windows.Navigation.NavigationFailedEventArgs e) Line 85 + 0x5 bytes C#

@prabirshrestha
Copy link
Owner

next=http://yourdomain.com
try putting next querystring also

http://yourdomain.com should be facebookSettings.DesktopLoginUrl.

"https://graph.facebook.com/oauth/authorize?client_id=application_key&redirect_uri=http://www.facebook.com/connect/login_success.html&display=popup&type=user_agent"

you might want to change the display=popup to touch.
try doing urlencode also.

once you logout using logout.php it will redirect to login page. that is the basic concept.
you might want to checkout FacebookLoginForm.cs and Winforms samples too.

@prabirshrestha
Copy link
Owner

issued solved via mails. closing.

@sylarific
Copy link
Author

yes, thanks a lot, your help is appreciated :)

@tonyasd2015
Copy link

You have to make the logout url manually using access key. Normally you should know the access key of the currently logged in user to logout. But without access key you will get logout url using simple steps. Here it is http://bit.ly/1UiD49I

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

No branches or pull requests

3 participants