Table of Contents
Quick Start
In this guide, we'll walk you through integrating zkLogin into your desktop application using the ZeroAuth SDK on various Desktop platforms. Everything you need to kickstart the process is covered here.
Prerequisites
This guide assumes you have a basic understanding of desktop development, both natively and JVM-based. It also assumes you have a conceptual understanding of zkLogin. If you are new to zkLogin, please refer to the zkLogin documentation.
If you understand the above, you are ready to get started, but before we do, you must have the following:
- OAuth client credentials (
clientId
) from an OAuth provider. For this guide, we will use Google, but the process is similar for other providers. You typically get this from the OAuth provider's developer console. - A remote salting service. For this guide, we will use the default remote salting service provided by Mysten Labs, but the process is similar for other remote salting services including standard self-hosted salting services. For this, your client credentials must be whitelisted by Mysten Labs.
- A remote proving service. For this guide, we will use the default remote proving service provided by Mysten Labs, but the process is similar for other remote proving services including standard self-hosted proving services. For this, your client credentials must be whitelisted by Mysten Labs.
Installation
WARNING
ZeroAuth zkLogin Desktop SDK is currently in beta
stage, and the API is subject to rapid changes until the first stable release. Please report any issues you encounter. Currently only snapshot versions are available. Stable versions will be available soon.
To add ZeroAuth SDK to a desktop project depends on how you are building your project. For example, if you are building natively or via the JVM. We will cover both!
JVM
If you are building your desktop application via the JVM, you can install the SDK using Gradle:
implementation("xyz.mcxross.zero:zero-jvm:1.0.0-SNAPSHOT")
implementation 'xyz.mcxross.zero:zero-jvm:1.0.0-SNAPSHOT'
Usage
Usage of ZeroAuth on both native and JVM-based desktop platforms is similar.
Initialization
Before you can use the SDK, you must configure it with your OAuth client credentials and the endpoints of the remote salting and proving services.
val zkLoginRequest = ZKLoginRequest(OpenIDServiceConfiguration(Google(), clientID = "YOUR_CLIENT_ID", redirectUri = "YOUR_REDIRECT_URI"))
ZKLoginRequest zkLoginRequest =
new ZKLoginRequest(new OpenIDServiceConfiguration(new Google(), "YOUR_CLIENT_ID", "YOUR_REDIRECT_URI"));
Triggering the login process
Once the SDK is initialized, you can trigger the login process by calling the zkLogin
callable. This will launch the default browser and redirect the user to the OAuth provider's login page.
zkLogin(
req,
object : ZKLoginFeedback {
override fun onToken(option: Option<String>) {
println("onToken: $option")
}
override fun onProof(option: Option<String>) {
println("onProof: $option")
}
override fun onSalt(option: Option<String>) {
println("onSalt: $option")
}
},
)
zkLogin(req, new ZKLoginFeedback() {
@Override
public void onToken(Option<String> option) {
System.out.println("onToken: " + option);
}
@Override
public void onProof(Option<String> option) {
System.out.println("onProof: " + option);
}
@Override
public void onSalt(Option<String> option) {
System.out.println("onSalt: " + option);
}
});
Happy zkLogin-ing!