Skip to content

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.

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

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:

ParameterTypeRequiredDescription
options.providerstringYesLogin method name (obtained from getAuthProviders)

Return value: ThirdPartyCredential

FieldTypeDescription
providerstringLogin method name (always present)
tokenstringMain receipt (Google=ID Token, Apple=Identity Token)
authorizationCodestringAuthorization Code (for some Providers)
emailstringUser email
displayNamestringUser Display Name
photoUrlstringUser avatar URL
rawobjectProvider raw data

Different providers return different fields; only provider is guaranteed to exist.

Error Code:

codeMeaningSuggested handling
CANCELLEDUser cancels loginSilent processing, no error prompt displayed.
PROVIDER_NOT_FOUNDUnregistered ProviderCheck the return value of getAuthProviders
NOT_IMPLEMENTEDHost app has not implemented LoginServiceContact the host app developer
ERROROther errorsDisplay error message