Skip to content

Instantly share code, notes, and snippets.

@theinventor
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theinventor/9220893 to your computer and use it in GitHub Desktop.
Save theinventor/9220893 to your computer and use it in GitHub Desktop.
This is an example of a couple actions that would tie together with the omniauth/google stuff
class SessionsController < ApplicationController
def new
redirect_to '/auth/google_oauth2'
end
def create #google oauth callback endpoint
@account = Account.find session[:account_id]
auth = request.env["omniauth.auth"]
@account.settings.google_calendar_uid = auth['uid']
@account.settings.google_calendar_token = auth[:credentials][:token]
@account.settings.google_calendar_refresh = auth[:credentials][:refresh_token]
@account.settings.google_calendar_expires_at = 1346015233
@account.settings.google_calendar_expires = true
redirect_to "success_url", :notice => 'Authorized your google calendar!' and return
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment