Edits history of script submission #23131 for ' Get Current User (notion)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    /**
     * Get Current User
     * Get the bot user the token belongs to: its name, owner and workspace name and ID.
     */
    export async function main(auth: RT.Notion) {
      const response = await fetch(`https://api.notion.com/v1/users/me`, {
        headers: {
          Authorization: `Bearer ${auth.token}`,
          Accept: "application/json",
          "Notion-Version": "2026-03-11",
        },
      })
    
      if (!response.ok) {
        throw new Error(`${response.status} ${await response.text()}`)
      }
    
      return await response.json()
    }
    

    Submitted by hugo989 4 hours ago