OAuth Dance for Offline Game without Redirect URL

Jump to solution
cpoole2256
Community Novice

Hello Canvas Developers!

My team is producing an offline education game using the Unity game engine and we want to include Canvas functionality. Unity allows us to export a WebGL version of the game as an HTML page which we plan on having schools download and place in the course folders. Once there, the HTML page will automatically open and allow playing of the game in the browser without any server on our part. One problem: I noticed when researching the OAuth dance, you need a redirect URL which is where the user is send after they authenticate but its also where Canvas sends a code needed to finish the authentication. Because we're storing our game inside Canvas itself and we want to do this without any servers on my team's side, we were wondering how we should go about completing this part of the dance. Does that first GET command simply retrieve the code for our app anyway?

(We can't test it right this moment because our Canvas instance isn't set up but I'm just conducting research to make sure what we want to do can be done)

Thanks for the help!

-Christopher Poole###

0 Likes
1 Solution
pklove
Community Champion

For applications without a web sever ("native apps" in the Canvas doc), you can use urn:ietf:wg:oauth:2.0:oob as the redirect_url.. The redirect then goes to a page on the Canvas server with a URL like:

   .../login/oauth2/auth?code=047f524c6b1d8bd6522670....

The user can then copy the code and insert it into your non-server application.  The application can then get the token.

The main issue is having clear instructions to the end user about getting the code from the URL and putting it into your application.  It would be nice if Canvas would put the code on the actual web page with some sort of instructions.

BTW, for testing its easy to fire up a slightly old, but adequate, AWS AMI, or more recent versions at Bitnami.

View solution in original post