0

I've set up functionality to "Log in with Github" using Oauth, as described in this tutorial. It's working great, but I can't figure out how to give them a button to log out.

I've tried providing a button imitating Github's logout form (sending a POST request to https://github.com/logout) but it gives the user a Github error page with a Status code: 422 Unprocessable Entity.

I'm using Octokit.rb with Sinatra. Any thoughts?

bryanbraun
  • 3,025
  • 2
  • 26
  • 38
  • Would that SO answer be helpful? - http://stackoverflow.com/a/17225298/335418 – nulltoken Feb 15 '14 at 20:43
  • Not really, since like that poster, I don't want to store their user credentials or have them re-enter them. I know it's possible without user creds... the [sinatra_auth_github](https://github.com/atmos/sinatra_auth_github) gem (which I'm not using) [has logout functionality built in](https://github.com/atmos/sinatra_auth_github/search?q=logout%21&ref=cmdform). – bryanbraun Feb 15 '14 at 21:44

1 Answers1

1

I discovered that I need to expire their login session. I was using Rack::Session with Sinatra, so in my case, this was the solution:

get '/logout' do
  session.clear
end

See also: Deleting the current session with Rack::Session::Cookie

Community
  • 1
  • 1
bryanbraun
  • 3,025
  • 2
  • 26
  • 38