Back-End for Native Mobile Application
Summarize Flow
The native mobile app requests an authentication URL from the backend server.
The native mobile app opens the authentication URL through secure browser authentication session, which redirects the user to the sgID server for authorization.
The user authorizes using their Singpass mobile app, and consents to share their data with the application.
The sgID server sends an authorization code to a web URL which opens up to mobile app through universal links or web links, which performs a callback redirect to the backend server's callback URL.
The backend server exchanges the authorization code for an access token and id token using its client ID and secret.
The backend server then uses access token an obtain encrypted user information from sgID server.
The backend server will then handle native mobile app authentication.
Complete Flow Diagram
auth/login
and /auth/callback
endpoints are to be developed by RP as these endpoints serve as primary communication channel between RP Mobile App and RP Server.
Client Authentication Recommendation
Token-based authentication
Token-based authentication is a mechanism where the server creates a JSON Web Token (JWT) after successful authentication. The JWT is then sent to the client as a response to the authentication request, and the client stores the JWT in local storage or in a cookie. The client includes the JWT in subsequent requests, allowing the server to identify the user.
In this mechanism, client authentication is handled by the server, which creates a JWT after successful authentication. The JWT is then sent to the client, and the client includes the JWT in subsequent requests. The server can then verify the JWT to authenticate the client.
Best Practices
Last updated