summaryrefslogtreecommitdiff
path: root/app/controllers/google_api/authorizations_controller.rb
blob: 1fafd7e88be4c92c736b4714162d0aa09c0103ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
module GoogleApi
  class AuthorizationsController < ApplicationController
    # /google_api/authorizations/callback(.:format)
    def callback
      # TODO: Error handling
      session[GoogleApi::CloudPlatform::Client.token_in_session] = 
        GoogleApi::Authentication.new(nil, callback_google_api_authorizations_url)
                                 .get_token(params[:code])

      if params[:state]
        redirect_to params[:state]
      else
        redirect_to root_url
      end
    end
  end
end