Authentication without an existing ID system
If your application does not have an implicit authorization, then then you may not have an inGamePlayerId
generated for your users to pass into the SocialLoginClient
upon initialization. Halliday's SocialLoginClient
supports the case where inGamePlayerId
is not defined, in which we will generate and set the inGamePlayerId
to be the player's Halliday Smart Account Address.
You can follow the same guides to set up Log In with Google, Facebook, and Twitter, and simply not pass in
inGamePlayerId
to use Auth With Halliday!
The returned SocialLoginClient
will have the generated inGamePlayerId
, and you can also retrieve the currently logged-in user's inGamePlayerId
with SocialLoginClient.getLoggedInPlayerId()
. This is required before refreshing the client.
Finally, be sure to log out the client when the user's session is finished!
Below is a sample integration of Auth with Halliday, using Log In with Google as an example:
import { useState } from "react";
import { BlockchainType, LogInWithGoogleButton, SocialLoginClient } from "halliday-sdk";
export default function LoginComponent() {
const [client, setClient] = useState<SocialLoginClient>();
useEffect(() => {
// Since you do not have an inGamePlayerId, read it from the current active session
// This is required before calling getCurrentSocialLoginClient for it to refresh properly!
const inGamePlayerId = SocialLoginClient.getLoggedInPlayerId();
const hallidaySocialLoginParams = {
hallidayPublicApiKey: YOUR_HALLIDAY_API_KEY,
sandbox: true,
inGamePlayerId: inGamePlayerId,
blockchainType: BlockchainType.SEPOLIA
}
const hallidayClient = await SocialLoginClient.getCurrentSocialLoginClient(
hallidaySocialLoginParams
);
setClient(hallidayClient); // setClient can be null.
}, []);
if (client == null) {
return (
<LoginWithGoogleButton
hallidayPublicApiKey={"YOUR_HALLIDAY_API_KEY"}
sandbox={false}
blockchainType={BlockchainType.MUMBAI}
setClient={setClient}
// note the absence of inGamePlayerId -- we will generate one for you
/>
);
}
// Upon user logging out, be sure to call logout!
return (
<button onClick={() => client.logOut()}>
Log Out
</button>
);
}
Beta: EIP-1271 Signatures
To be able to authenticate your user on your server, we will send an EIP-1271 signature that is sent from the user's Halliday Smart Account address for you to verify against the inGamePlayerId
. This is currently in development, stay tuned for future updates!
Updated 28 days ago