I use gem OAuth2 to communicate with Google services. I do not understand how to implement a callback that receives a response with OAuth code in order to get an access token. When I set a breakpoint in the callback method, it never calls the call.
Here is my code:
Routes
match '/oauth2/callback' => 'reports#callback'
Actual redirected URL:
http:
ReportsController:
def new client = OAuth2::Client.new(ENV['GA_CLIENT_ID'], ENV['GA_SECRET_KEY'], { :authorize_url => 'https://accounts.google.com/o/oauth2/auth', :token_url => 'https://accounts.google.com/o/oauth2/token' }) redirect_to client.auth_code.authorize_url({ :scope => 'https://www.googleapis.com/auth/analytics.readonly', :redirect_uri => 'http://localhost/oauth2/callback', :access_type => 'offline' }) end def callback oauth_code = params[:code]
source share