Your script obtains the access token for Microsoft Graph API, to call your custom API, you need to obtain the access token for the AD App which represents your API.
Navigate to the portal -> Azure Active Directory
-> App registrations
-> find the AD App which represents your API -> Expose an API
-> get the Application ID URI
(if you didn't set it, click Set
to set it).
Then in your script, change the $MapUrl
with it.
$MapUrl="Application ID URI"
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…