Coder Social home page Coder Social logo

clever-example-app's Introduction

Example Clever App

A barebones app that implements SIgn Up With Clever, using Node.js and Express 4.

You can try it out yourself at https://clever-example-app.herokuapp.com/

Running Locally

Make sure you have Node.js and the Heroku CLI installed.

$ git clone [email protected]: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:

  1. Add a "Sign Up with Clever" button to your application's signup page, that directs the user to the Clever /oauth/authorize endpoint 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

  2. Implement a route in your app to handle when the OAuth request returns from Clever, that dose the following:

    a. Exchanges a single-use code for a longer-lived token that can be used with the Clever API.

    b. Hits the /v2.0/me endpoint 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.

  3. 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 clever.js file.

To access information about the currently Clever user, you can use the Clever API, making user's Instant Login Bearer Token.

clever-example-app's People

Contributors

zeke avatar jonmountjoy avatar hunterloftis avatar jmorrell avatar raul avatar samccone avatar scantini avatar theneva avatar friism avatar r0mdau avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.