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

0vote

How can I get the user_id so I can use it in the API

How can I get the user_id so I can use it in the API

2 Answers

0vote

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 Points78860

0vote

ggblake commented

Not very helpful...
Obviously I can get the user ID wjen using the API but I need to get it before I can use the API so I can build a Notionclient.
So, how can I get it without using the API

0vote

polle commented

You asked: How can I get the user_id so I can use it in the API

Now you changed to without the API?

Why not spend at least 3 minutes explaining what are you trying to do instead of pasting a line 2 times without explaining anything?

The more time you spend asking, the more time people will spend helping you.

1vote

ggblake commented

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);
}

Thanks for all the help.

0vote

polle commented

Much better, for sure someone will be able to help you with the explanation.

I see that this question is wrong and you opened a new one here which I assume is the correct one.

Please select the answer to mark this one as solved and receive help in the new one.

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