I'm implementing a SoundCloud login flow in my app. The app opens https://soundcloud.com/connect
in an SFSafariViewController
with a redirect_uri
that uses my app's custom URL scheme to receive the response. It works fine for direct SoundCloud logins, but fails when trying to use their "Sign in with Google" button.
In Safari, that button opens a new tab (popup on desktop) with a Google sign-in page, which then communicates back to the SoundCloud tab via postMessage
. This login flow works fine if you use the iOS Safari app, but fails in an SFSafariViewController
(clicking the button goes to a white page with a Google url: https://accounts.google.com/o/oauth2/auth?...
).
Right now my workaround is to advise users using Google to tap the Safari icon on the SFSafariViewController
to complete the login flow in the Safari app, but I'm wondering if there's a way to handle this without leaving my app.
Well, if I use a
UIWebView
, you can grab the final oauth response from google after the user authenticates with Google. However, how do we turn that back around to SoundCloud (e.g.soundcloud.com/connect/via/google_plus/returning
)Output:
The URL that initiates the google login step is below -- I've decoded the URL escape encoding below for convenience: