GitHub App Installation flow on mobile+web (multi platform)?

I’m preparing to submit the app to the Marketplace.

The app has three versions: Web, Electron and Mobile.

Since setting up the “Setup URL” is required by Marketplace, I made it redirect to the root url (myappname.com?installation_id=123).

It works fine.

But how about on mobile? How do I make it redirect to a different URL or something like that?

Because it shouldn’t redirect to myappname.com web version, it should trigger the myapp:// app scheme. Same thing for Electron. Any suggestion?

What I suggest is something similar to the oauth flow: If I could pass a query variable like “state” to the installation url (e.g. github.com/apps/app-name/installations/new/permissions?target_id=123 &state=MYSTATEHERE &maybeothervar=123) and GitHub included this query variable when redirecting to the Setup URL (myappname.com/setup-url ?state=MYSTATEHERE ) then I would be able to handle it.

But since this isn’t possible, any suggestion?

I’ve just come up with a hacky solution:

  1. Instead of redirecting directly from the app to github, redirect to myserver.com/install/app?platform=mobile instead.

  2. This endpoint will save the app type (web/electron/mobile) as a cookie or localstorage.

  3. Redirects to github and install the app

  4. GitHub redirects to another endpoint of mine: myserver.com/install/app/callback?installation_id=123

  5. This endpoint will check the cookie/localstorage, so now it knows the platform and what to do next. E.g. if mobile, redirect to myappscheme://. 

2 Likes