I am trying to use AppAuth to get an auth code from Instagram, redirect to my server, and exchange that auth code for a custom Firebase token. I'm having problems passing data to AppAuth and triggering the browser window to close.
What works so far
- Mobile app registers a custom scheme,
myscheme:/
- AppAuth hits Instagram authorize endpoint, receives valid
code
, redirects tohttps://myserver.com
- AppAuth hits
https://myserver.com
, providescode
, is waiting for response - My server hits Instagram token endpoint, exchanges
code
/etc for validtoken
- My server uses this
token
to mint a validFirebase token
At this point AppAuth browser window is open and waiting for a response from my server. The server has the Firebase token
. The desired next step is to provide this token to AppAuth and have AppAuth close the browser window and complete the process.
What I've tried:
- Return a redirect to
myscheme:/instagram?token=Firebase token
This closes the AppAuth browser window but the process does not complete so AppAuth does not return any result. It continues to wait even though the browser window is closed.
- Setup a custom scheme listener and redirect to
myscheme:/instagram?token=Firebase token
This has the same outcome as 1. but the custom scheme listener does not capture this event, and even if it did, I have no way to cancel the AppAuth process. This feels hacky at best.
To distill the question further:
What does AppAuth need to close the browser window and complete the handshake? What is it looking for?