{"action":"closed","issue":{"url":"https://api.github.com/repos/markbates/goth/issues/192","repository_url":"https://api.github.com/repos/markbates/goth","labels_url":"https://api.github.com/repos/markbates/goth/issues/192/labels{/name}","comments_url":"https://api.github.com/repos/markbates/goth/issues/192/comments","events_url":"https://api.github.com/repos/markbates/goth/issues/192/events","html_url":"https://github.com/markbates/goth/issues/192","id":286216710,"number":192,"title":"Example code not working: gorilla/sessions attempts to delete newly created session.","user":{"login":"Omustardo","id":7197679,"avatar_url":"https://avatars3.githubusercontent.com/u/7197679?v=4","gravatar_id":"","url":"https://api.github.com/users/Omustardo","html_url":"https://github.com/Omustardo","followers_url":"https://api.github.com/users/Omustardo/followers","following_url":"https://api.github.com/users/Omustardo/following{/other_user}","gists_url":"https://api.github.com/users/Omustardo/gists{/gist_id}","starred_url":"https://api.github.com/users/Omustardo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Omustardo/subscriptions","organizations_url":"https://api.github.com/users/Omustardo/orgs","repos_url":"https://api.github.com/users/Omustardo/repos","events_url":"https://api.github.com/users/Omustardo/events{/privacy}","received_events_url":"https://api.github.com/users/Omustardo/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-01-05T07:55:34Z","updated_at":"2018-04-12T22:15:11Z","closed_at":"2018-04-12T22:15:11Z","author_association":"NONE","body":"I'm attempting to get a basic example of google oauth working. As a base case, I tried running the example code provided in goth/examples but upon clicking the \"Log in with Google Plus\" button it responded with a text based web page saying:\r\n\"remove C:\\Users\\Omar\\AppData\\Local\\Temp\\session_: The system cannot find the file specified.\"\r\n\r\nThat error comes from a line in gorilla/sessions where the [FilesystemStore.erase](https://github.com/gorilla/sessions/blob/master/store.go#L287) fails to find a file, so my best guess was that there must have been an error saving the session.\r\n\r\nI reported this to [gorilla/sessions](https://github.com/gorilla/sessions/issues/137) and they suggested that the package is being misused to get to this state.\r\n\r\n\r\nI read more about oauth since I'm new to it, and realized I would need to set up a real domain name in order to avoid having to deal with redirect mismatches #94 so I modified the provided demo to:\r\n1. only use gplus as a provider\r\n2. use my own server cert/key for TLS\r\n3. use my own callback url\r\nMy code is here: https://gist.github.com/Omustardo/09ae0eb5a3edf3d0d2520d14143d8c46\r\n\r\n\r\nI've finally had some time to dig into it, and I found out what's happening. \r\nLooking at the code, the point of failure is on [FilesystemStore.Save](https://github.com/gorilla/sessions/blob/master/store.go#L216) when a session is provided that has Options.MaxAge==-1\r\n\r\nThe question is, how does it get a session with MaxAge==-1\r\nThe session that's causing the error is retrieved by [Store.Get(req, SessionName)](https://github.com/markbates/goth/blob/master/gothic/gothic.go#L284)\r\n\r\nUsing a debugger, I traced the path of Store.Get and found that the registry it retrieves from contains multiple SessionInfo entries, keyed by session name. In this case, the provided `SessionName` is a constant = \"_gothic_session\". As far as I can tell, the MaxAge for this session is always -1, so when we then try to save the session, it immediately attempts to erase the local file (at `os.TempDir() + sessions_`) which doesn't yet exist, and so it returns an error.\r\n\r\nI suspect I'm missing some key point, since clearly this example has worked for other people (I hope), but it looks to me like the wrong session is being retrieved from `Store.Get`. Looking at the registry, it contains an entry for \"_gothic_session\" as well as one for \"gplus_gothic_session\". The gplus one has MaxAge=2592000 which is what we want.\r\n\r\nBy modifying storeInSession and getFromSession to call `Store.Get(req, key + SessionName)` instead of `Store.Get(req, SessionName)` I was able to get the modified example code to work. I suspect there might be other places in the code where the providerName should be appended to the SessionName but haven't looked deeply yet.\r\n\r\nAm I doing something wrong, or should I submit a pull request to fix this?\r\n  \r\n  "}}
{"actor":{"display_login":"adamo57"}}