- Android API level 24 or later
- Java 11+
To install the SIWF SDK via Gradle, add the following to your build.gradle file:
dependencies {
implementation 'io.projectliberty:siwf:1.0.0'
}To create a SIWF Button in your Android app, use:
import io.projectliberty.siwf.Siwf
import io.projectliberty.models.SiwfButtonMode
Siwf.CreateSignInButton(
mode = SiwfButtonMode.PRIMARY,
authRequest = authRequest
)authRequest requires the Signed Request Payload in either base64url encoded or structured form.
Update your AndroidManifest.xml with your own intent filters for authentication callbacks.
Then, use a BroadcastReceiver() to receive the authorization code with AuthConstants.AUTH_INTENT_KEY.
Example:
<activity
android:name="io.projectliberty.helpers.AuthCallbackActivity"
...
<intent-filter android:autoVerify="true">
...
<data
android:scheme="http"
android:host="localhost"
android:port="3000"
android:path="/login/callback" />
</intent-filter>
<intent-filter android:autoVerify="true">
... or ...
<data
android:scheme="siwfdemoapp"
android:host="login" />
</intent-filter>
</activity>On your backend service, process the authorization code and start your session.
Resources: