Skip to main content
The launcher skin supports third-party sign-in with OAuth2. It comes set up for Google, and you can adapt it to other providers.

Turn on OAuth

Set useOAuth to true in public/app.yaml. The launcher then shows its OAuth sign-in component, which gets an access token from the provider using one of these methods:

How sign-in works

  1. The OAuth client builds the authorization URL from your configuration.
  2. The launcher shows the provider’s sign-in page using the method you chose.
  3. The player signs in, and the provider redirects to the callback URL you registered with it.
  4. The launcher gets the authorization code or access_token from the callback:
    • Popup or frame: the callback page, oauth.html, sends the result to the launcher window and closes the popup.
    • Browser: the callback URL points to the launcher’s internal web server. When it’s requested with a code, the launcher fires a SkinApp.NewAuthCode notification and redirects the browser to webServer.oauth.successUrl or webServer.oauth.errorUrl.

Choose a callback URL

Localhost callback

If your provider allows a localhost callback, set the ports the launcher’s web server can use:
app.yaml
The launcher uses the first open port. If none are open, it shows an error when it starts. Register each as an allowed callback, in the form http://127.0.0.1:<port>/. To get the address and port the launcher picked, use app.expandString("{contentUrl}") when you build the authorization URL.

Callback on your own domain

Some providers don’t allow localhost callbacks. With CEF, the launcher can internally redirect a request for a URL on your own domain to oauth.html. This is called resource rewriting. Register a URL on a domain you own, then set it up in loadOAuthConfig() in src/redux/OAuth.js:

Browser method

With the browser method, the provider redirects to the redirectUrl in your OAuth client. Point it to an endpoint on the launcher’s internal web server, and set the same endpoint as webServer.oauth.redirectUrl. For example, if redirectUrl is app.expandString("{contentUrl}auth2"), set webServer.oauth.redirectUrl to auth2:
app.yaml

Set up Google sign-in

The skin comes with a sample Google configuration. Replace it with your own.

Create the Google client

  1. In the Google Cloud console, go to APIs & Services → Credentials.
  2. Click Create Credentials → OAuth client ID.
  3. Set Application type to Web application.
  4. Under Authorized redirect URIs, add the callback URLs you chose.
  5. Copy the client ID.
While your app is in development, add each tester to the list of users on the app’s OAuth consent screen page.

Configure the skin

Edit GOOGLE_OAUTH_CONFIG in src/constants/OAuthConfig.js:
  • Set clientId to your client ID.
  • Set redirectUrl to the callback URL you registered.
Google requires a newer Chrome than the CEF version in DirectGVR. Set the CEF user agent in app.yaml:
app.yaml
To exchange the authorization code for refresh and access tokens with OAuthResponseType.CODE, you need the Google client secret. See the comments in the same file and Google’s OAuth 2.0 for desktop apps. OAuthResponseType.TOKEN doesn’t return refresh tokens, so players would sign in every time they open the launcher. Providers implement OAuth2 differently. To change how the launcher talks to yours, edit src/oauth/OAuthClient.js.