Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
bertique
Level 7

OAuth in scene graph app

Hi there,

I've been converting an app from the "old" api to the scene graph format. I've got the main scene working, as well as the oauth flow (according to the auth-linking-channel sample).

Now I'm just stumped on how to connect the two, as in pass the oauth token from the oauth scene to the main scene. I'm pretty new, so not sure what the recommended flow is:
1. Create the auth scene first, and when successful load the main scene, and somehow pass the token (global variable etc).
2. Embed the auth scene in the main scene, and hide the main stuff until the auth is done, then hide auth
3. Try to read the auth from the registry through the main scene

It seems weird that for every start of the app (after the initial auth), I'd have to create the auth scene, just to see if the user was previously auth'ed? Appreciate any help or a sample on how this flow usually works in a scene graph app. Thanks much!
0 Kudos
2 Replies
RokuLeoW
Level 7

Re: OAuth in scene graph app

Hi Bertique,

I think a good flow would be a combination of 2. and 3.:
On channel start (i.e. when the user opens the channel), you can use the RegistryTask component to first read from registry to check whether or not the channel has been authenticated. 
- If the user is not authenticated, you can use the UriHandler component to make a request to the content provider's server until you receive an auth token. 
- If the user is authenticated, you can skip the previous step entirely and show the home page of your channel/whatever content that comes after linking. 
When you say "embedding the auth scene in the main scene," I wouldn't necessarily "embed" in the strictest sense but I would take the necessary components -- the "RegistryTask" and "UriHandler" components -- and put them into the scene of your channel, use them as needed and, like you said, hide them when auth is done. The other components in the sample (scene included) were made solely for demonstration purposes. It would indeed be odd to create an auth scene and then move on to your own scene; I suggest that the navigation flow be handled by the logic that you write in your scene (if logged in --> show content screen, if not logged in --> show login screen, etc.) Smiley Happy  

Hope that helps!
0 Kudos
bertique
Level 7

Re: OAuth in scene graph app

Thanks, that was helpful. I believe I have it working now more or less. Still some difficulty adjusting, coming from other programming languages Smiley Happy
0 Kudos