Accesstoken not available after reopening website - asp.net-mvc

I have a MVC 3 website with the Facebook C# SDK.
Now i'm redoing the facebook integration in a clean MVC 4 application with the new version 6 of the sdk. So I used the gettings started help page on the sdk website. http://csharpsdk.org/docs/web/getting-started
I've followed the tutorial and changed only one part of the tutorial. The thing that I changed was that I call an Controller Action because the ashx was fired but wasn't allowed to set the accesstoken in the Session object. The Session was null.
Now when I start the website for the first time (used Chrome because IE won't work by default. The tutorial explains why.), I see the login button.
When I press the login button, I get the authorize page of facebook that asks that my app wants to connect to my facebook account. When I submit, the MVC action in the controller gets fired and the given accesstoken is stored in the session.
After that I can access my own information.
When I close Visual Studio (IIS express is closed with it) and restart the website, the login button is changed to my account with picture that says that I use the app that is connected. After that I navigate back to the page with my own information and get a nullreferenceexception on the session that gets the accesstoken. Why is that? Why is the user logged in but the action that stores the accesstoken isn't fired the second time that I open the website (new session).
Shouldn't I set the app secret somewhere? I have set the AppId in the javascript following the tutorial.
Thanks.

Per Facebook your user is logged into your app, but since you restarted your Cassini web server, your "session" is gone/lost/deleted.
Check your session to ensure you have a valid token, in session, if not redirect the user to your login code.

Related

Using a URL to log a user out of a developer web app and redirect to another URL

I have an app that all works fine for authentication and it uses Oauth2 (Google).
Now, I am struggling with the logout URL for this app. It works, but I am under the impression that it is possible to logout of it and remain logged into my gmail account please? Currently, ALL accounts are logged out of so the two gmail accounts need to go through login each time the app is used and log out is pressed.
I have read that this is possible but this is the URL that I am using to Log out
https://www.google.com/accounts/Logout?continue=https://appengine.google.com/_ah/logout?continue=http://news.bbc.co.uk
I am sure it can be done because I did it in a former role but do not have the code!

Facebook iOS SDK 4.x: changing the user to log in

I'm upgrading Facebook SDK from 3.x to 4.x and need to log in as different Facebook users to my application (game) in order to check if FB requests work correct.
In 3.x login dialog switched to FB application, so I could change the user in the FB application and got new credentials for my login. Now I only got "You have already authorised..." message in a Safari-view login dialog.
I changed user in FB application several times as well as uninstalled my application in order to clean its local cache - nothing helps. My application always logs in as User 1, even if I logged in as User 2 in FB application.
How can I login as a different user (clear saved token, got a credentials dialog or something else)?
You need to log in fb from Safari and exit the user =)

Build web page request in Objective C

I'm building a native application. The app has an embedded webview (UIWebView) pointing to a social website. To be able to use the website inside the app, user has to log in by the webview (username/password) and then he can continue use the site with saved cookies. Normally, the cookies expire after two days. After that, the user has to re-login by the webview.
Now suppose I know username and password of the user and I would like to make the user login automatically with this account when the cookie expires. How can I do that?
I tried to simulate the Login action when I click on Login button on web page, but not successful.By using "Inspect Element" of Chrome, I can see Chrome makes a "Post" request to an URL with some parameters. However, the request doesn't get successful (I use REST client for testing).
Finally I found out the solution. I didn't build requests anymore. I used javascript to set text fields and make "click" action on the webview. Done.

After a site rebuild on first login the session is destroyed after redirect

I am currently getting an issue after an ASP.NET MVC 4 site is rebuilt that I was not getting previously.
We log in to a 3rd party site that redirects to our site with an authentication payload. A Session_Start is hit and the payload is successfully processed and a Session variable with the users details is created. We then do a RedirectToAction to send the user to another page.
On the first login after the site has been rebuilt Session_Start is hit again and a new Session is being created on the Redirect where previously it was not doing this. As our site checks for and treats an invalid session as being incorrect it sends the user back to the 3rd party site to log in again. When next they login they do not get this issue.
This looks to be happening when the site recycles as well. It only occurs for the very first user that logins to the site after its been rebuilt.
This only began happening in the last 2 weeks and I have reviewed any changes that went into the site in that time but could not find an obvious cause of the issue.
Any help would be appreciated.

Facebook authentication in a new browser instance Asp.net MVC

I have an Asp.Net MVC 4 app an i have a feature in which the app can post to user's wall.
Its working fine, but currently the url
https://www.facebook.com/dialog/oauth?client_id=XXXXX&redirect_uri=http://localhost:xxxxxx/&scope=publish_stream
redirects to facebook page , authenticates ,post the message and redirects back to my app.
Is it possible to open the facebook authentication page in a new browser instance and somehow close the browser instance once the message is posted ?
Thanks !
Not sure if this covers what you want to achieve but by using Facebook Feed Dialog, you can set display parameter to appropriate value (e.g. popup) and let the user publish a story to a timeline.

Resources