Generate A New Heroku Api Key
How should I generate an API key that allows me to use the Heroku Platform API? Your API key has expired unexpectedly and you're receiving 403 Forbidden errors when hitting API endpoints. Use heroku authorizations:create for production apps, use heroku auth:token for development. There are multiple ways to create API keys and all of them have different expiration. To secure your app, you might want to use JSON Web Tokens (JWTs) to create an access token/refresh token which you would send as a header to the API. Implementing JWTs is a bit more of an involved process, but the simplest way you can restrict traffic to an endpoint is using an API key. Editor's note: This is a cross post from Blake Gentry, an engineer at Heroku. This is a post about the recently announced Heroku Platform API JSON Schema and how I used that schema to write an auto-generated Go client for the API. Heroku's API team has spent a large part of the past year designing a new version of the platform API.While this is the 3rd incarnation of the API, neither of the.
The Heroku provider is used to interact with the resources provided by HerokuPlatform API and needs to be configured with credentials before it can be used.
» Background
Heroku is a fully-managed platform that gives you thesimplest path to delivering apps quickly: /wolfenstein-2009-cd-key-generator.html.
» Contributing
Development happens in the GitHub repo:
» Example Usage
» Authentication
The Heroku provider offers a flexible means of providing credentials forauthentication. The following methods are supported, listed in order ofprecedence, and explained below:
- Static credentials
- Environment variables
- Netrc
» Static credentials
Credentials can be provided statically by adding email
and api_key
argumentsto the Heroku provider block:
» Environment variables
When the Heroku provider block does not contain an email
or api_key
argument, the missing credentials will be sourced from the environment via theHEROKU_EMAIL
and HEROKU_API_KEY
environment variables respectively:
» Netrc
Credentials can instead be sourced from the .netrc
file in your home directory:
» Argument Reference
The following arguments are supported:
api_key
- (Required) Heroku API token. It must be provided, but it can alsobe sourced from other locations.email
- (Required) Email to be notified by Heroku. It must be provided, butit can also be sourced from other locations.headers
- (Optional) Additional Headers to be sent to Heroku. If notprovided, it will be sourced from theHEROKU_HEADERS
environment variable(if set).delays
- (Optional) Delays help mitigate issues that can arise due toHeroku's eventually consistent data model. Only a singledelays
block may bespecified and it supports the following arguments:post_app_create_delay
- (Optional) The number of seconds to wait after anapp is created. Default is to wait 5 seconds.post_space_create_delay
- (Optional) The number of seconds to wait after aprivate space is created. Default is to wait 5 seconds.post_domain_create_delay
- (Optional) The number of seconds to wait aftera domain is created. Default is to wait 5 seconds.
If you wish to install Heroku using the one-click deployment process, please click the purple 'Deploy to Heroku' button in the repository home page.
Installation Instructions
Installing UDOIT using the Heroku button is very easy, but still requires some setup. If you prefer to watch a video demonstrating the process step-by-step, watch the UDOIT Installation CanvasLIVE video.
Below are the written directions if you prefer to follow along that way.
Step 1: Create a Google/YouTube and Vimeo API keys
See the Google/YouTube API instructions and Vimeo API instructions in the README.
Generate A New Heroku Api Key Free
Step 2: Setting up Heroku
After clicking the Heroku button above:
- Create an account (if you don't have one already).
- Give the app a name.
- Set
OAUTH2_ENFORCE_SCOPES
to true if you have a scoped developer key. - Fill out the
OAUTH2_ID
andOAUTH2_KEY
fields with dummy data. (We'll fix it later.) - Fill out the
OAUTH2_URI
field withhttps://yourapp.herokuapp.com/oauth2response.php
. (Replace 'yourapp' with the name you gave in step 2.) - Fill out the
CANVAS_NAV_ITEM_NAME
field with the name you would like the app to appear as in the course navigation menu. This is useful if your instance will be use for a pilot. The normal value to use here is UDOIT. - (optional) Copy and paste your Google/YouTube API key into the
GOOGLE_API_KEY
field. - (optional) Copy and paste your Vimeo API key into the
VIMEO_API_KEY
field. - (optional) If you have a Google Analytics account, you can paste your site tracking code into the
GA_TRACKING_CODE
field. - (optional) If you would like to enable the Admin Panel, change the
ADMIN_PANEL_ENABLED
field totrue
. - Click the Deploy button and wait for the process to complete.
Step 3: Request a Developer Key
Generate A New Heroku Api Key 2018
UDOIT uses Oauth2 to take actions on behalf of the user, so you'll need to ask your Canvas administrator to generate a Developer Key for you. (If you are an admin, go to your institution's account administration page in Canvas and click on 'Developer Keys'.) Here is the information you need to provide them:
- Key Name: Probably UDOIT or UDOIT Test for your test instance
- Owner Email: The email address of whoever is responsible for UDOIT at your institution
- Redirect URI: This is the URI of the
oauth2response.php
file in the UDOIT directory. - This should be
https://yourapp.herokuapp.com/oauth2response.php
. (Replace 'yourapp' with the name of your UDOIT instance on Heroku.) - Icon URL: The URL of the UDOIT icon. This is
https://yourapp.herokuapp.com/assets/img/udoit_icon.png
. (Replace yourapp with the name of your UDOIT instance on Heroku.)
Scoped Developer Keys
If you'd like to use this option, you'll need set the following scopes for your developer key.
- Assignments
- url:GET /api/v1/courses/:course_id/assignments
- url:GET /api/v1/courses/:course_id/assignments/:id
- url:PUT /api/v1/courses/:course_id/assignments/:id
- Courses
- url:PUT /api/v1/courses/:id
- url:GET /api/v1/courses/:id
- url:POST /api/v1/courses/:course_id/files
- Discussion Topics
- url:GET /api/v1/courses/:course_id/discussion_topics
- url:GET /api/v1/courses/:course_id/discussion_topics/:topic_id
- url:PUT /api/v1/courses/:course_id/discussion_topics/:topic_id
- Files
- url:GET /api/v1/courses/:course_id/files
- url:GET /api/v1/courses/:course_id/folders/:id
- url:GET /api/v1/folders/:id/folders
- url:GET /api/v1/folders/:id/files
- Modules
- url:GET /api/v1/courses/:course_id/modules
- url:GET /api/v1/courses/:course_id/modules/:module_id/items
- Pages
- url:GET /api/v1/courses/:course_id/pages
- url:GET /api/v1/courses/:course_id/pages/:url
- url:PUT /api/v1/courses/:course_id/pages/:url
- Users
- url:GET /api/v1/users/:user_id/profile
Step 4: Add your Developer Key to UDOIT
- In Heroku, click the 'Manage App' button for your install of UDOIT.
- Go to the 'Settings' tab.
- Copy and paste the following values from the Developer Key:
- ID into OAUTH2_ID
- Secret into OAUTH2_KEY
- Verify that your OAUTH2_URI is correct. (See above.)
Step 5: Install the UDOIT LTI
In Canvas, you can install UDOIT at the course or sub-account levels.
- Click the Settings menu item from any course in Canvas.
- Click the Apps tab.
- Click the View App Configurations button.
- Click the Add App button.
- Under Configuration Type, choose By URL.
- In the Name field, enter
UDOIT
. - In the Consumer Key field, copy the value from CONSUMER_KEY
- In the Shared Secret field, copy the value from SHARED_SECRET
- In the Config URL field, insert https://yourapp.herokuapp.com/udoit.xml.php (Replace yourapp with the name of your UDOIT instance on Heroku.)
- Finish by clicking Submit.
UDOIT should now be available in the course navigation menu.
Warning: Recommended for advanced users only
You can use our configuration to launch a new Heroku app using Heroku's app-setups api.
You'll have to set some env settings. Peek at app.json for any env vars that don't have 'required': false
set. Our config vars are covered in Configure section
Create The App: MAKE SURE you modify the env values
Read the result to make sure it returned an id, not an error.
Check your Heroku dashboard or install the Heroku CLI and run heroku apps
to see if a new app shows up. If all goes well, it should be running.
Configure
These variables can be set in the curl post above. You can also set them later using heroku config:set VAR=value1
CONSUMER_KEY
- LTI consumer key entered when adding UDOIT LTI to CanvasSHARED_SECRET
- LTI secret entered when adding UDOIT LTI to CanvasOAUTH2_ID
- from the developer api key created by your adminOAUTH2_KEY
- from the developer api key created by your adminOAUTH2_URI
- full url to your oauth2response.php - EX:https://your.herokuapp.com/oauth2response.php
GOOGLE_API_KEY
- add a google api key for youtube video supportUSE_HEROKU_CONFIG
- set totrue
to enable the Heroku configuration
To modify the code on your running Heroku server, you'll need to push code to it.
Set up the git repository:
Link the git repository to your Heroku App
Build and Deploy
Peeking at Database Tables
The Heroku install process should create the tables for you.
If you need to check that the tables exist, you can connect to Postgres using some convenient Heroku functions. You'll need to have Postgresql installed on your own system to do the following commands.
heroku pg:psql
will open a psql connection to the remote Heroku databasedt
will show you a list of the tables you just createdd reports
andd users
should describe the tablesSelect * from users;
orSelect * from reports;
will show you their contentsq
quits the psql terminal
If needed, you can manually run the table creation script: heroku run composer db-setup
Table Schema
The table schema can be found in migrations/
When it comes time to update UDOIT to the latest version, you probably don't want to have to start over from scratch using the Heroku Button (as explained above). Luckily, there's a procedure for upgrading an existing installation, which allows you to keep your existing database, settings, and URL.
First Time Setup
This process takes a while to set up the first time, but is very fast after that. On your computer: Java key pair generator algorithms.
- Install Git
- Install Heroku CLI and follow the instructions to get your account set up.
- Clone the UDOIT Git repository. If you are using a command line interface, navigate to a directory where you would like the code to live and run this command:
git clone git@github.com:ucfopen/UDOIT.git
. This will create a folder calledUDOIT
that contains the latest version. - In your command line interface, navigate into the newly-created
UDOIT
folder. - Run
heroku git:remote --app your-heroku-instance
, replacingyour-heroku-instance
with your actual heroku instance name. For example, if your UDOIT instance resides athttps://udoit-pcu.herokuapp.com
, you would runheroku git:remote --app udoit-pcu
. This adds your Heroku instance as a remote calledheroku
in the Git repository so that you can push updates to it in the future.
Pushing Updates to Heroku
Now that your computer is set up, you only need to follow these steps each time you would like to update your instance of UDOIT:
- In your command line interface, navigate to the
UDOIT
directory on your computer. - Run
git checkout master
to make sure we're on the master branch, which represents the latest version of UDOIT. - Run
git pull
to update your local copy of UDOIT from the official GitHub repository. - Run
git push heroku master:master
to deploy the new version to your UDOIT instance. - Run
heroku run --app your-heroku-instance 'php composer.phar migrate'
to update the database structure for your UDOIT instance. (Remember to replaceyour-heroku-instance
with your Heroku instance name.) - Log into the Heroku website and click on your UDOIT instance.
- Click Settings
- Under the Config Vars heading, click Reveal Config Vars.
- Compare them to the
env
section of app.json, and add any missing variables to Heroku.
UDOIT should now be up to date with the latest release!
Dealing with Multiple Heroku Instances
First Time Setup (Test Instance)
The sections above assume you only have a single Heroku instance. However, we recommend you always have two instances: one for testing and one for production. That way, you can test out the deploy on your test instance without risking any downtime on your production instance. If you don't have a test instance, just use the Heroku Button to create one. Assuming you set everything up for your production instance in the First Time Setup section above, here's how to set up your testing instance (sometimes called 'staging' or 'QA'):
- In your command line interface, navigate to the
UDOIT
directory on your computer. - Run
heroku git:remote --remote test --app your-heroku-test-instance
, replacingyour-heroku-test-instance
with your actual heroku test instance name. For example, if your UDOIT instance resides athttps://udoit-pcu-test.herokuapp.com
, you would runheroku git:remote --remote test --app udoit-pcu-test
. This adds your Heroku test instance as a remote calledtest
in the Git repository so that you can push updates to it in the future.
Feel free to name the remote anything you want. It doesn't have to be test
; it could be staging
or qa
or blah
. It's best to make it something descriptive, though.
Heroku Developer
Pushing Updates to the Test Instance
Now that you have the connection to the test instance set up, here's how to push an update to it:
- In your command line interface, navigate to the
UDOIT
directory on your computer. - Run
git checkout master
to make sure we're on the master branch, which represents the latest version of UDOIT. - Run
git pull
to update your local copy of UDOIT from the official GitHub repository. - Run
git push test master:master
to deploy the new version to your UDOIT test instance. - Run
heroku run --app your-heroku-test-instance 'php composer.phar migrate'
to update the database structure for your UDOIT test instance. (Remember to replaceyour-heroku-test-instance
with your Heroku test instance name.) - Log into the Heroku website and click on your UDOIT test instance.
- Click Settings
- Under the Config Vars heading, click Reveal Config Vars.
- Compare them to the
env
section of app.json, and add any missing variables to Heroku.
Why aren't my scans completing?
If you are using the free tier, you may need to manually turn on the worker dyno. You can do this by going to the Heroku Control Panel, selecting your instance of UDOIT, clicking Configure Dynos, clicking the pencil icon next to the Worker dyno, clicking the slider to the on position, then clicking Confirm.