Generating the URL

The base URL is https://bitbadges.io/siwbb/authorize, with parameters appended to it.

For instance:

https://bitbadges.io/siwbb/authorize?name=Event&description=...

This URL structure adheres to the following interface:

You can use https://bitbadges.io/auth/linkgen or the code below to generate the URL. The URL is to be distributed to your users via any communication method or directly in your frontend. The generated URL can be quite long, so you may consider using a URL shortener.

Snippets

import { generateBitBadgesAuthUrl, CodeGenQueryParams } from 'bitbadgesjs-sdk';

const popupParams: CodeGenQueryParams {
    ...
} // See Authentication URL page

const authUrl = generateBitBadgesAuthUrl(popupParams);
export const generateBitBadgesAuthUrl = (params: CodeGenQueryParams) => {
    let url = `https://bitbadges.io/siwbb/authorize?`;
    for (const [key, value] of Object.entries(params)) {
        if (value) {
            if (typeof value === 'object') {
                const valueString = JSON.stringify(value);
                const encodedValue = encodeURIComponent(valueString);
                url = url.concat(`${key}=${encodedValue}&`);
            } else {
                url = url.concat(`${key}=${value}&`);
            }
        }
    }
    return url;
};

Last updated