5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'app/controllers/canvas_oauth/canvas_controller.rb', line 5
def oauth
if verify_oauth2_state(params[:state]) && params[:code]
if token = canvas.get_access_token(params[:code])
if CanvasOauth::Authorization.cache_token(token, user_id, tool_consumer_instance_guid)
redirect_to main_app.root_path
else
render plain: "Error: unable to save token"
end
else
render plain: "Error: invalid code - #{params[:code]}"
end
else
render plain: "#{CanvasOauth::Config.tool_name} needs access to your account in order to function properly. Please try again and click log in to approve the integration."
end
end
|