Sha256: aa4dfc78958a40d1ea4e4fc8e0fb8d94ee5da40728a4bdfee194e3cf51d30cf8

Contents?: true

Size: 611 Bytes

Versions: 1

Compression:

Stored size: 611 Bytes

Contents

# require "canvas-embed"

class ApplicationController < ActionController::Base
  def generate_token
    # this is the secret signing key from Canvas
    key_hex = ENV['CANVAS_SIGNING_KEY']
    # this should be updated to include the scopes needed for your charts and that are
    # appropriate for the user
    begin
      scopes = ActiveSupport::JSON.decode params[:scopes]
    rescue StandardError => e
      return render :json => { "message" => "Scopes were not valid JSON" }, status: 500
    end
    token = Canvas::Embed::generate_token(key_hex, scopes)
    render :json => { "token" => token }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
canvas-embed-0.1.4 example/app/controllers/application_controller.rb