Next.js Discord

Discord Forum

Eartho Auth and Payments In Next.js - Getting error 401

Unanswered
Yellow-breasted Bunting posted this in #help-forum
Open in Discord
Yellow-breasted BuntingOP
I'm trying to use this tool called Eartho, which offers free authentication and payments, but I keep getting a 401 error with this code. Has anyone else encountered this issue before?
It should open a popup like in the image I added, thanks !!!

// src/App.js
import React from 'react';
import { useEarthoOne } from '@eartho/one-client-react';

function App() {
const {
isLoading,
isConnected,
error,
user,
connectWithPopup,
logout,
} = useEarthoOne();

if (isLoading) {
return <div>Loading...</div>;
}
if (error) {
return <div>Oops... {error.message}</div>;
}

if (isConnected) {
return (
<div>
Hello {user.displayName}{' '}
<button onClick={() => logout({ returnTo: window.location.origin })}>
Log out
</button>
</div>
);
} else {
return <button
className="btn btn-outline-success"
id="login"
onClick={() => connectWithPopup({ accessId: "YOUR_EARTHO_ACCESS_ID" })}
>
Log in
</button>;
}
}

export default App;

0 Replies