Server-side Redirects

When using server-side redirects you provide the URL of the API endpoint that will receive the token and other login session details as parameters. The native app will redirect the webview to this URL after a successful login. If the user has cancelled the login process, the error parameter will contain an error message.

Median JavaScript Bridge Methods and Parameters:

median.socialLogin.facebook.login({ 'redirectUri' : '<endpoint>', 'scope' : '<text>' });
median.socialLogin.google.login({ 'redirectUri' : '<endpoint>' });
median.socialLogin.apple.login({ 'redirectUri' : '<endpoint>', 'scope' : '<text>' });

redirectUri - the GET endpoint that will be called after using the Social Login. The tokens will be added as GET parameters.
scope - determines what data your app would like access to. Check the official documentation for each of the social logins for more information.

Redirect URL API Endpoint parameters:

Identity ProviderStatusParametersExample
Facebook LoginSuccessaccessToken=STRING
type=facebook
https://yoursite.com/auth/facebook/redirect?accessToken=example&type=facebook&userId=1234567890
Facebook LoginErrorerror=STRING
type=facebook
https://yoursite.com/auth/facebook/redirect?error=error&type=facebook
Google Sign-inSuccessidToken=STRING
type=google
https://yoursite.com/auth/google/redirct?idToken=example&type=google
Google Sign-inErrorerror=STRING
type=google
https://yoursite.com/auth/google/redirect?error=error&type=google
Sign in with AppleSuccessidToken=STRING
code=STRING
firstName=STRING1
lastName=STRING1
type=apple
https://yoursite.com/auth/apple/redirect?idToken=example&code=example&firstName=John&lastName=Doe&type=apple
Sign in with AppleErrorerror=STRING
type=apple
https://yoursite.com/auth/apple/redirect?error=error&type=apple

🚧

[1] User profile only sent for initial login

Apple only returns a user's complete profile with fields such as firstName and lastName the first time the user authenticates for your app. You must securely save the user profile information for future purposes as subsequent authorization requests will only contain an identity token in the form of JSON Web Token (JWT), authorization code, and user identifier to your app. Parsing the JWT will return additional fields such as email, email_verified, etc. Refer to this documentation for more info.

Example:

<button class="google-login native-only" 
  onclick="median.socialLogin.google.login({ 'redirectUri' : 'https://median.dev/social-login/redirect-demo/redirect.html' });">
	Log in With Google
</button>

In this example, the Median JavaScript Bridge endpoint is activated when the anchor tag is clicked. After the user has logged in within the native app, the webview will be redirected to https://median.dev/social-login/redirect-demo/redirect.html?idToken=example.