Hello Diane König,
Welcome to the Microsoft Q&A and thank you for posting your questions here.
I understand that you are having multiple errors with logic app and SharePoint.
By the below three best practices steps, you should be able to resolve both the decoding and authentication issues and successfully create folders in SharePoint using your Logic App.
Step 1: Resolve IDX14102 (Token Decoding Issue), this issue indicates a problem with the token returned by Azure AD.
- You will need to verify the token by:
- Decode the token using jwt.io - to ensure it is valid. Check for the following:
- The token must be well-formed (header.payload.signature).
- The header must include the alg (algorithm) and typ (type) fields.
- The payload must include claims such as aud (audience) and scp (scope).
- Then, in your application settings, enable PII logging to get more details on the error:
IdentityModelEventSource.ShowPII = true;
- Verify Azure AD Setup by doing the following:
- Ensure the app registration's
client_id
andclient_secret
match those used in your Logic App. - Confirm the
tenant_id
is correct. - Check the token endpoint URL:
https://login.microsoftonline.com/<tenant_id>/oauth2/v2.0/token
Step 2: Fix 401 Unauthorized (Invalid Token)
1.Go to **Azure AD > App Registrations > Your App > API Permissions.
- Add Microsoft Graph API permissions:
- Delegated Permissions:
Sites.ReadWrite.All
. - Application Permissions:
Sites.ReadWrite.All
. - Click Grant Admin Consent to approve these permissions.
- Verify Token Scope and Audience:
- The
scope
in the token request should be: https://graph.microsoft.com/.default - Use a tool like
jwt.io
to ensure the token includes:-
`aud`: `https://graph.microsoft.com`
-
`scp`: `Sites.ReadWrite.All`
-
- Then, grant SharePoint Access to use the AppInv page in SharePoint to grant permissions:
- Navigate to
https://<your-site>.sharepoint.com/_layouts/15/appinv.aspx
. - Enter the
client_id
of your app. - Set permission XML:
- Navigate to
<AppPermissionRequests AllowAppOnlyPolicy="true">
<AppPermissionRequest Scope="http://sharepoint/content/sitecollection" Right="Write" />
</AppPermissionRequests>
4. Click Create and confirm.
Step 3: Test Endpoints
- Use
Postman
orFiddler
to test the token generation and folder creation API calls directly. - Ensure the Authorization header is:
Authorization: Bearer <token>
I hope this is helpful! Do not hesitate to let me know if you have any other questions.
Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful.