A basic HTML/JavaScript app demonstrating the Device Authorization Request and Device Access Token Request of the Oauth2 Device Authorization Grant specification.
Use in conjunction with an installation of FusionAuth to demo the entire Device Grant workflow.
- Download and install FusionAuth
- Create an Application
- Enable Device Grant on the OAuth tab under "Enabled grants"
- Enter a Device Verification URL.
- This URL should be as short (and sweet) as possible.
- This URL will be either landing page to your application that can perform a
302redirect to the FusionAuth device page with the required request parameters or a URL configured in a proxy to perform the same redirect. - For example,
https://acme.com/activatewhich would be able to redirect tohttps://login.acme.com/oauth2/device?client_id={client_id}&tenantId={tenantId}wherehttps://login.acme.comis the URL of your FusionAuth service.
- Click save (blue icon at the top right).
- Update the FusionAuth CORS policy
- Add
http://localhost:8080to "Allowed origins" - Check "POST" as an "Allowed methods"
- Click save.
- Add
- Edit the
main.jsfile in this project- Change
baseFusionAuthURLto your base FusionAuth URL - Change
clientIdto that of the newly created Application in the previous step
- Change
- Run this example
- Run
python3 -m http.server --bind 127.0.0.1to start a simple HTTP server for theindex.htmlfile. - Open
http://localhost:8080in your browser - Click the "Click to Start" button
- Browse to the URL provided and enter the code or scan the QR code with your phone.
- Run