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.
GoNative JavaScript Bridge Methods and Parameters:
gonative.socialLogin.facebook.login({ 'redirectUri' : '<endpoint>', 'scope' : '<text>' });
gonative.socialLogin.google.login({ 'redirectUri' : '<endpoint>' });
gonative.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 Provider | Status | Parameters | Example |
---|---|---|---|
Facebook Login | Success |
| https://yoursite.com/auth/facebook/redirect?accessToken=example&type=facebook&userId=1234567890 |
Facebook Login | Error |
| https://yoursite.com/auth/facebook/redirect?error=error&type=facebook |
Google Sign-in | Success |
| https://yoursite.com/auth/google/redirct?idToken=example&type=google |
Google Sign-in | Error |
| https://yoursite.com/auth/google/redirect?error=error&type=google |
Sign in with Apple | Success |
| |
Sign in with Apple | Error |
| https://yoursite.com/auth/apple/redirect?error=error&type=apple |
- Apple only returns the user's information the first time the user authorizes the app. Persist this information from your app; subsequent authorization requests won’t contain this information.
Example:
<button class="google-login native-only"
onclick="gonative.socialLogin.google.login({ 'redirectUri' : 'https://gonative-social-logins-demo.web.app/auth/google/redirect' });">
Log in With Google
</button>
In this example, the GoNative 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://gonative-social-logins-demo.web.app/redirect?idToken=example
.
Updated 3 months ago