Notion Answers

Help between Notion users


Register & Ask

It's free & easy

Get answers

Answers, votes & comments

Vote and select answers

Receive points, vote and give the solution

Question

1vote

How do I get user ID without using the API

I'm trying to use the Notion API for Java. To build a Notion client one of the parameters required is user id. Getting a page id or a database id is easy ( extracting it from the url shown in the browser.

I need a user_id and a token (to substitute for the ??'s below)

import org.jraf.klibnotion.client.*;

private static final String TOKEN = "??";

// Replace this constant with a user id that exists
private static final String USER_ID = "???";

// Replace this constant with a database id that exists
private static final String DATABASE_ID = "4187ea78084040079c1ce6ea6e605cc1";

// Replace this constant with a page id that exists
private static final String PAGE_ID = "db4f55eb9f6b4fd089562f82ebb6335e?v=b031267784c8464883952c89a11626f0&pvs=4";

private void initClient() {
    NotionClient notionClient = NotionClient.newInstance(
            new ClientConfiguration(
                    new Authentication(TOKEN),
                    new HttpConfiguration(
                            // Uncomment to see more logs
                            // loggingLevel = HttpLoggingLevel.BODY,
                            HttpLoggingLevel.INFO,
                            null,
                            // This is only needed to debug with, e.g., Charles Proxy
                            new HttpProxy("localhost", 8888),
                            true
                    )
            )
    );
    client = BlockingNotionClientUtils.asBlockingNotionClient(notionClient);
}

private void main() {
    initClient();

    // Get user
    System.out.println("User:");
    User user = client.getUsers().getUser(USER_ID);
    System.out.println(user);
}

1 Answer

1vote

ggblake Points360

There is no direct way to get your user_id through UI. However, you can follow these steps to get the user id:
Open Network tab of Developer tools on your browser in the same tab as where Notion is opened.
On the Notion UI, click on Settings & members.
Click on My account and check the Network call authGetLoginConfiguration and in the preview you should see an attribute called userId.

0vote

polle commented

Thank you for sharing your solution, for sure it will help someone else.

Please log in or register to answer this question.

...

Welcome to Notion Answers, where you can ask questions and receive answers from other members of the community.

Please share to grow the Notion Community!

Connect