#r "nuget: FSharpPlus"
#r "nuget: Auth0.Core"
#r "nuget: Auth0.ManagementApi"
open FSharpPlus
open System.Threading.Tasks
open Auth0
open Auth0.ManagementApi
open Auth0.ManagementApi.Models
let token = "..."
let client = Auth0.ManagementApi.ManagementApiClient(token, "https://redacted.ca.auth0.com/")
let req = GetUsersRequest()
let result = client.Users.GetAllAsync(req).Result
System.AggregateException: One or more errors occurred. (The format of value 'Bearer
’ is invalid.)
The token is valid JWT tested on JWT.io generated from the Auth0 Management API page. It also works in the docs.
The error strongly suggests that the token string being passed to the ManagementApiClient contains unexpected whitespace characters—most commonly a newline or an extra space—either before or after the actual JWT. The Auth0.ManagementApi client, which uses HttpClient internally, is very strict about the format of the Authorization header.
You can try using the .Trim() method to remove the whitespace from the token.