Login
The SDK provides third-party login bridging capabilities. H5 triggers native third-party login (e.g., Google, Apple) via the SDK. After obtaining the third-party credentials, the application calls its backend to exchange them for a token.
getAuthProviders()
Section titled “getAuthProviders()”Obtain the list of third-party login methods supported by the host app.
const providers = await SuperSDK.getAuthProviders();// ['google', 'apple']Return value: string[] — Array of Provider names
requestLogin(options)
Section titled “requestLogin(options)”Trigger third-party login via the specified method.
try { const credential = await SuperSDK.requestLogin({ provider: 'google' }); console.log(credential.provider); // 'google' console.log(credential.token); // Primary Receipt (Google ID Token / Apple Identity Token) console.log(credential.authorizationCode); // Authorization Code console.log(credential.email); // User email console.log(credential.displayName); // username
// After obtaining the receipt, the H5 independently calls the backend to exchange for the business token. const res = await fetch('/api/auth/login', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(credential) }); const { token } = await res.json();} catch (e) { if (e.message === 'CANCELLED') { // User cancels, no error dialog shown. } else { console.error('Sign-in failed:', e.message); }}Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| options.provider | string | Yes | Login method name (obtained from getAuthProviders) |
Return value: ThirdPartyCredential
| Field | Type | Description |
|---|---|---|
| provider | string | Login method name (always present) |
| token | string | Main receipt (Google=ID Token, Apple=Identity Token) |
| authorizationCode | string | Authorization Code (for some Providers) |
| string | User email | |
| displayName | string | User Display Name |
| photoUrl | string | User avatar URL |
| raw | object | Provider raw data |
Different providers return different fields; only
provideris guaranteed to exist.
Error Code:
| code | Meaning | Suggested handling |
|---|---|---|
| CANCELLED | User cancels login | Silent processing, no error prompt displayed. |
| PROVIDER_NOT_FOUND | Unregistered Provider | Check the return value of getAuthProviders |
| NOT_IMPLEMENTED | Host app has not implemented LoginService | Contact the host app developer |
| ERROR | Other errors | Display error message |