Edits history of script submission #23531 for ' Get Current User (ms_sharepoint)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    const graph = "https://graph.microsoft.com/v1.0"
    
    /**
     * Get Current User
     * Get the profile of the connected account (id, display name, mail, user principal name). Requires User.Read (a connection default).
     */
    export async function main(auth: RT.MsSharepoint) {
      const response = await fetch(`${graph}/me`, {
        headers: {
          Authorization: `Bearer ${auth.token}`,
          Accept: "application/json",
        },
      })
    
      if (!response.ok) {
        throw new Error(`${response.status} ${await response.text()}`)
      }
    
      return await response.json()
    }
    

    Submitted by hugo989 5 hours ago