Harsh Kanakhara
Harsh Kanakhara

Reputation: 1153

Mule 4 - OAuth authorization dance not yet performed for resourceOwnerId in Sharepoint Connector

I am using Sharepoint Connector in Mule 4 to get file content using OAuth 2.0.

Under Azure AD I registered a new app and perform the following steps:

After registering my new app I am setting up API permissions for Sharepoint. For app type, I am selecting Application Permissions as my app is running as a background service and doesn't require any signed-in user to be present.

Granted all the permissions for Microsoft Graph and Sharepoint with Admin Consent.

Sharepoint connector in Mule requires scope and resourceOwnerId. As scope value, I am passing the scope name which I have created while registering my app. For resourceOwnerId below is the string format I am passing ResourceId/mypoc2022.sharepoint.com@TenantId.

For Scope below are the values I have tried:

For ResourceId below are the values I have tried:

Tried toggling the SSL certification validation while setting up the configuration properties for Sharepoint but still got the following error after starting my server.

OAuth authorization dance not yet performed for resourceOwnerId

Note: While hitting http://localhost:8081/authorize I am able to receive the authorization code. But not using the Mulesoft connector. I am not allowed to use the browser as manual intervention is not allowed.

Below is my configuration

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:sharepoint="http://www.mulesoft.org/schema/mule/sharepoint" xmlns:http="http://www.mulesoft.org/schema/mule/http"
    xmlns="http://www.mulesoft.org/schema/mule/core"
    xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/sharepoint http://www.mulesoft.org/schema/mule/sharepoint/current/mule-sharepoint.xsd">
    <http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="1df5227d-0a5d-40d2-a79b-dac07224dcd4" >
        <http:listener-connection host="0.0.0.0" port="8081" />
    </http:listener-config>
    <sharepoint:sharepoint-online-config name="Sharepoint_Sharepoint_online" doc:name="Sharepoint Sharepoint online" doc:id="74e86dd4-c0f4-46a8-a375-d239d002fd9e" >
        <sharepoint:oauth-authorization-code-connection siteUrl="https://mypoc2022.sharepoint.com" disableCnCheck="true">
            <sharepoint:oauth-authorization-code consumerKey="GENERATED_CLIENT_ID" consumerSecret="GENERATED_CLIENT_SECRET" authorizationUrl="https://login.microsoftonline.com/<TENANT_ID_PASSED_HERE>/oauth2/v2.0/authorize" accessTokenUrl="https://login.microsoftonline.com/<TENANT_ID_PASSED_HERE>/oauth2/v2.0/token" scopes="https://sharepoint/content/sitecollection" resourceOwnerId="https://graph.microsoft.com/https://mypoc2022.sharepoint.com@TENANT_ID_PASSED_HERE" after="sp-pocFlow" />
            <sharepoint:oauth-callback-config listenerConfig="HTTP_Listener_config" callbackPath="/callback" authorizePath="/authorize" externalCallbackUrl="http://localhost:8081/callback"/>
        </sharepoint:oauth-authorization-code-connection>
    </sharepoint:sharepoint-online-config>
    <flow name="sp-pocFlow" doc:id="980aca08-56fe-42fd-a5d2-470b80e357c8" >
        <http:listener doc:name="Listener" doc:id="45f0a24f-444d-4a06-b0a4-368968e56f2d" config-ref="HTTP_Listener_config" path="/api"/>
        <sharepoint:file-get-content doc:name="File get content" doc:id="fdb714ce-ed3c-4bb0-8366-63ee277af8bc" config-ref="Sharepoint_Sharepoint_online" fileServerRelativeUrl="/Shared Documents/sample.pdf"/>
    </flow>
</mule>

Upvotes: 0

Views: 2323

Answers (0)

Related Questions