Identity Provider

The Minefinity identity provider provides a simple, secure way to authenticate who a Minecraft user is.

Please connect to :25565
You're ()! 👋
Oh no, the request timed out 😞
Verified Response:

Create the connection

First, use EventSource in the client to open a connection to https://identity.minefinity.io/v1/auth. You'll receive an `init` payload with the hostname:

// Create connection
const src = new EventSource('https://identity.minefinity.io/v1/auth');

// Listen for first event
src.addEventListener('init', ({ data }) => {
	const { hostname, timeout } = JSON.parse(data);
	console.log(`Send the user to ${hostname}, this request times out in ${timeout}ms`);
	// Send the user to aquamarine-pleased-parakeet.id.minef.in, this request times out in 20000ms
});
				

Handle response

Once connected, you should wait for either `done` or `timeout` to be fired. If done is returned, you will be given a validation token.

// Listen for done
src.addEventListener('done', ({ data }) => {
	const { username, uuid, token } = JSON.parse(data);

	console.log(`Hi ${username}/${uuid}!`);
	// Hi Notch/069a79f4-44e9-4726-a5be-fca90e38aaf5!
	console.log(`Verify: ${token}`);
	// Verify: ey...
});

// Listen for timeout
src.addEventListener('timeout', () => {
	// The request timed out.. up to you!
});
				

Verify Connection

Since we need to be able to verify this data in a backend environment, you can pass this token to a backend for verifying. Just throw an API call towards the Minefinity API:

// Done
src.addEventListener('done', ({ data }) => {
	const { token } = JSON.parse(data);

	// Pass this somewhere else, to your backend app, etc.
	const verificationToken = token;

	const resp = await fetch(`https://identity.minefinity.io/v1/verify?token=${verificationToken}`, { headers: { 'Accept': 'application/json' }})
		.catch(e => e)
	const res = await pl.json();
	if (resp.status === 200) {
		console.log(`Hi ${res.username} (${res.uuid}))`);
	} else {
		console.log('Request timed out');
	}
});