@ankr.com/auth
v5.5.0
Published
### Usage
Readme
Helper for https://auth.ankr.com/ integration
Usage
Initialize sign in
document.location = getSignInUrl({
authPath: 'https://auth.ankr.com/',
appPath: 'ankr.com/rpc/auth/',
appId: 'MultiRPC',
referralCode: 'foobar',
hasReferralCodeBox: true,
hasClickwrapAgreement: true,
hasAPIKeysNotification: true,
referrer: window.location.href,
});Get access token and init getaways
import {
getPermanentAccessTokenWithCookie,
getSignInUrl,
signOutAndClearCookies,
useAuth,
} from '@ankr.com/auth';
export const gateways = createGateways({ baseURL: 'https://api.project.com/v1/' });
export function Component({ children }: IAppBaseProps): JSX.Element {
const { isSignedIn } = useAuth({
appId: 'MultiRPC',
getPermanentAccessToken: getPermanentAccessTokenWithCookie,
signOutFromAPI: signOutAndClearCookies,
gateways,
customAuthAPIBaseURL: `https://api.project.com/v2/`,
});
const getUser = () => {
void gateways.auth.get('/getUser');;
};
if (isSignedIn === undefined) {
return <QueryLoadingAbsolute />;
} else {
getUser();
}
return null;
}