How to use NoVa Auth?

1. Prepare URL

params = new URLSearchParams({
    who: "your api key", // You can get your api key from https://nova-auth.vercel.app/me
    callback: "https://your-website.com/callback",
    want: "username,avatar,verified", // You can request any of the following fields: username, avatar, verified, email
});  

let url = "https://nova-auth.vercel.app/auth?" + params.toString(); // This is the URL you need to redirect the user to

2. Callback Response

# In your callback page, you'll recieve either of this 2 return types
1. If success is true ->  token =  URL encoded access token
2. If success is false -> error = error message

# Here's how the response URL might look like:
- https://your-website.com/callback?success=true&token=access_token

3. Using the access token

// This is how you can use the access token to get the user's data
// request user info
let res = await fetch('https://nova-auth.vercel.app/api/user', {
    method: 'GET',
    headers: {
        'Authorization': accessToken
    }
});

// Handle errors...
// 400 - Bad Request: No access token provided
// 401 - Unauthorized: Invalid access token
if (!res.ok) {
    // handle the error
    return;
}

// get the response body -- User data
let data = await res.json();

// do something with the data. Remember that only the fields you requested will be returned
let user: {
    username: string, 
    avatar: string, 
    verified: boolean
} = data;

That's it! You can now use NoVa Auth to authenticate users on your website.

Acess Tokens are NOT TIME LIMITED, once approved the can be used forever until users remokes the access.