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