Example Clever App
You can try it out yourself at https://clever-example-app.herokuapp.com/
$ git clone firstname.lastname@example.org:brettcvz/clever-example-app.git # or clone your own fork $ cd clever-example-app $ npm install
Then, edit the
.env file to add your Clever Client ID and Clever Client Secret. These can be found on your Clever Dashboard under the "Settings" tab.
Now, run the app:
$ npm start
Your app should now be running on localhost:5000.
Implementing "Sign Up with Clever"
The basic sequence to implement Sign Up with Clever is as follows:
Add a "Sign Up with Clever" button to your application's signup page, that directs the user to the Clever
/oauth/authorizeendpoint with the correct parameters for your app. You can also add a "Log In with Clever" button that points to the same URL. Button assets can be found in the Clever Dev Docs
Implement a route in your app to handle when the OAuth request returns from Clever, that dose the following:
a. Exchanges a single-use
codefor a longer-lived
tokenthat can be used with the Clever API.
b. Hits the
/v2.0/meendpoint to get the user's Clever ID
c. Checks to see a user with that Clever ID already exists. If so, log the user in to your app. If not, hit the Clever API to request the user's name, classes, etc. and create the corresponding user in your app.
Send the now logged in user to your app's home page.
At step 2.c., you may want to ask the user if they already have an existing account, and if so, if they want to associate their Clever ID with their existing account.
For more details on how to perform an OAuth connection with Clever, see the Clever Dev Docs, or look at the
runOAuthFlow method in the