summaryrefslogtreecommitdiff
path: root/app/controllers/google_api/authorizations_controller.rb
blob: 890b4ce60c8e0b79431207f7bdf91fa158e9d4c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
module GoogleApi
  class AuthorizationsController < ApplicationController
    def callback
      token, expires_at = GoogleApi::CloudPlatform::Client
        .new(nil, callback_google_api_authorizations_url)
        .get_token(params[:code])

      session[GoogleApi::CloudPlatform::Client.session_key_for_token] = token
      session[GoogleApi::CloudPlatform::Client.session_key_for_expires_at] =
        expires_at.to_s

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