Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

Reply
nsprudhvi
Advocate I
Advocate I

Unauthorized Error in Airflow Task with Microsoft Fabric Plugin (401 Invalid Client)

Hi everyone,

I'm encountering an issue while running an Airflow task that interacts with Microsoft Fabric using the apache_airflow_microsoft_fabric_plugin. The task fails with a 401 Unauthorized error, and the logs indicate the following:

 

 

 

invalid_client: The request body must contain the following parameter: 'client_assertion' or 'client_secret'. 
Trace ID: 54844adb-4acd-4720-a99f-8b71ad921100 
Correlation ID: fd79265c-dd63-457b-aa31-50ed665fec2d 
Timestamp: 2024-10-04 12:18:02Z

 

 

 

 

It seems the OAuth2 request is missing either a client_assertion or client_secret. I've verified that my Azure app registration has a client secret configured and that my Airflow connection (fabric-airflow-conn) is set up with the correct credentials.

Here's the traceback:

 

 

 

[2024-10-04, 14:18:02 CEST] {base.py:73} INFO - Using connection ID 'fabric-airflow-conn' for task execution.
[2024-10-04, 14:18:02 CEST] {taskinstance.py:1824} ERROR - Task failed with exception
Traceback (most recent call last):
  File "/home/airflow/.local/lib/python3.8/site-packages/apache_airflow_microsoft_fabric_plugin/hooks/fabric.py", line 132, in _get_token
    response.raise_for_status()
  File "/home/airflow/.local/lib/python3.8/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://login.microsoftonline.com/117c4e93-3230-40d6-b1cd-57cdee469b2f/oauth2/v2.0/token
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/airflow/.local/lib/python3.8/site-packages/apache_airflow_microsoft_fabric_plugin/operators/fabric.py", line 122, in execute
    self.location = self.hook.run_fabric_item(
  File "/home/airflow/.local/lib/python3.8/site-packages/apache_airflow_microsoft_fabric_plugin/hooks/fabric.py", line 214, in run_fabric_item
    headers = self.get_headers()
  File "/home/airflow/.local/lib/python3.8/site-packages/apache_airflow_microsoft_fabric_plugin/hooks/fabric.py", line 161, in get_headers
    "Authorization": f"Bearer {self._get_token()}",
  File "/home/airflow/.local/lib/python3.8/site-packages/apache_airflow_microsoft_fabric_plugin/hooks/fabric.py", line 135, in _get_token
    raise AirflowException(msg)
airflow.exceptions.AirflowException: Response: {"error":"invalid_client","error_description":"AADSTS7000218: The request body must contain the following parameter: 'client_assertion' or 'client_secret'. Trace ID: 54844adb-4acd-4720-a99f-8b71ad921100 Correlation ID: fd79265c-dd63-457b-aa31-50ed665fec2d Timestamp: 2024-10-04 12:18:02Z","error_codes":[7000218],"timestamp":"2024-10-04 12:18:02Z","trace_id":"54844adb-4acd-4720-a99f-8b71ad921100","correlation_id":"fd79265c-dd63-457b-aa31-50ed665fec2d","error_uri":"https://login.microsoftonline.com/error?code=7000218"} Status Code: 401
[2024-10-04, 14:18:02 CEST] {taskinstance.py:1345} INFO - Marking task as FAILED. dag_id=Run_Fabric_Item, task_id=run_fabric_notebook, execution_date=20241004T121800, start_date=20241004T121801, end_date=20241004T121802
[2024-10-04, 14:18:02 CEST] {standard_task_runner.py:104} ERROR - Failed to execute job 104 for task run_fabric_notebook (Response: {"error":"invalid_client","error_description":"AADSTS7000218: The request body must contain the following parameter: 'client_assertion' or 'client_secret'. Trace ID: 54844adb-4acd-4720-a99f-8b71ad921100 Correlation ID: fd79265c-dd63-457b-aa31-50ed665fec2d Timestamp: 2024-10-04 12:18:02Z","error_codes":[7000218],"timestamp":"2024-10-04 12:18:02Z","trace_id":"54844adb-4acd-4720-a99f-8b71ad921100","correlation_id":"fd79265c-dd63-457b-aa31-50ed665fec2d","error_uri":"https://login.microsoftonline.com/error?code=7000218"} Status Code: 401; 50)
[2024-10-04, 14:18:02 CEST] {local_task_job_runner.py:225} INFO - Task exited with return code 1

 

 

 

Has anyone else encountered this issue or have insights into how to resolve it?

 

Thanks in advance!

1 ACCEPTED SOLUTION
v-zhengdxu-msft
Community Support
Community Support

Hi @nsprudhvi 

 

Here are a few steps you can take to resolve this issue:

The error message suggests that the request body must contain either a client_assertion or client_secret. Make sure these parameters are included in your authentication request.

Verify that your configuration settings for basic authentication are correctly set up. This includes checking your tenant ID and other relevant settings.

You can try to re-generate your tokens according to this document:

OAuth 2.0 client credentials flow on the Microsoft identity platform - Microsoft identity platform |...

 

Here's a link for your reference:

requests.exceptions.HTTPError: 401 Client Error · Issue #10 · ambika-garg/apache-airflow-microsoft-f...

 

Best Regards

Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-zhengdxu-msft
Community Support
Community Support

Hi @nsprudhvi 

 

Here are a few steps you can take to resolve this issue:

The error message suggests that the request body must contain either a client_assertion or client_secret. Make sure these parameters are included in your authentication request.

Verify that your configuration settings for basic authentication are correctly set up. This includes checking your tenant ID and other relevant settings.

You can try to re-generate your tokens according to this document:

OAuth 2.0 client credentials flow on the Microsoft identity platform - Microsoft identity platform |...

 

Here's a link for your reference:

requests.exceptions.HTTPError: 401 Client Error · Issue #10 · ambika-garg/apache-airflow-microsoft-f...

 

Best Regards

Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

I came across the same issue as reported above, but couldn't find the answer in these links. I finally resolved it by finding out that the Extra parameter in the Airflow Connector contained (as per documentation on various sites) "client_secret" : "xxxxx" while this should be "clientSecret" : "xxxxxx" Subtle, but time consuming. Even more so because the error message states that "client_secret" is missing. 

 

I wrote a full setup guide on my blog that also explores Semantic model refresh in a DAG : Orchestrate Fabric Data workloads with Airflow - Mattias De Smet

Helpful resources

Announcements
MarchFBCvideo - carousel

Fabric Monthly Update - March 2025

Check out the March 2025 Fabric update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.

"); $(".slidesjs-pagination" ).prependTo(".pagination_sec"); $(".slidesjs-pagination" ).append("
"); $(".slidesjs-play.slidesjs-navigation").appendTo(".playpause_sec"); $(".slidesjs-stop.slidesjs-navigation").appendTo(".playpause_sec"); $(".slidesjs-pagination" ).append(""); $(".slidesjs-pagination" ).append(""); } catch(e){ } /* End: This code is added by iTalent as part of iTrack COMPL-455 */ $(".slidesjs-previous.slidesjs-navigation").attr('tabindex', '0'); $(".slidesjs-next.slidesjs-navigation").attr('tabindex', '0'); /* start: This code is added by iTalent as part of iTrack 1859082 */ $('.slidesjs-play.slidesjs-navigation').attr('id','playtitle'); $('.slidesjs-stop.slidesjs-navigation').attr('id','stoptitle'); $('.slidesjs-play.slidesjs-navigation').attr('role','tab'); $('.slidesjs-stop.slidesjs-navigation').attr('role','tab'); $('.slidesjs-play.slidesjs-navigation').attr('aria-describedby','tip1'); $('.slidesjs-stop.slidesjs-navigation').attr('aria-describedby','tip2'); /* End: This code is added by iTalent as part of iTrack 1859082 */ }); $(document).ready(function() { if($("#slides .item").length < 2 ) { /* Fixing Single Slide click issue (commented following code)*/ // $(".item").css("left","0px"); $(".item.slidesjs-slide").attr('style', 'left:0px !important'); $(".slidesjs-stop.slidesjs-navigation").trigger('click'); $(".slidesjs-previous").css("display", "none"); $(".slidesjs-next").css("display", "none"); } var items_length = $(".item.slidesjs-slide").length; $(".slidesjs-pagination-item > button").attr("aria-setsize",items_length); $(".slidesjs-next, .slidesjs-pagination-item button").attr("tabindex","-1"); $(".slidesjs-pagination-item button").attr("role", "tab"); $(".slidesjs-previous").attr("tabindex","-1"); $(".slidesjs-next").attr("aria-hidden","true"); $(".slidesjs-previous").attr("aria-hidden","true"); $(".slidesjs-next").attr("aria-label","Next"); $(".slidesjs-previous").attr("aria-label","Previous"); //$(".slidesjs-stop.slidesjs-navigation").attr("role","button"); //$(".slidesjs-play.slidesjs-navigation").attr("role","button"); $(".slidesjs-pagination").attr("role","tablist").attr("aria-busy","true"); $("li.slidesjs-pagination-item").attr("role","list"); $(".item.slidesjs-slide").attr("tabindex","-1"); $(".item.slidesjs-slide").attr("aria-label","item"); /*$(".slidesjs-stop.slidesjs-navigation").on('click', function() { var itemNumber = parseInt($('.slidesjs-pagination-item > a.active').attr('data-slidesjs-item')); $($('.item.slidesjs-slide')[itemNumber]).find('.c-call-to-action').attr('tabindex', '0'); });*/ $(".slidesjs-stop.slidesjs-navigation, .slidesjs-pagination-item > button").on('click keydown', function() { $.each($('.item.slidesjs-slide'),function(i,el){ $(el).find('.c-call-to-action').attr('tabindex', '-1'); }); var itemNumber = parseInt($('.slidesjs-pagination-item > button.active').attr('data-slidesjs-item')); $($('.item.slidesjs-slide')[itemNumber]).find('.c-call-to-action').attr('tabindex', '0'); }); $(".slidesjs-play.slidesjs-navigation").on('click', function() { $.each($('.item.slidesjs-slide'),function(i,el){ $(el).find('.c-call-to-action').attr('tabindex', '-1'); }); }); $(".slidesjs-pagination-item button").keyup(function(e){ var keyCode = e.keyCode || e.which; if (keyCode == 9) { e.preventDefault(); $(".slidesjs-stop.slidesjs-navigation").trigger('click').blur(); $("button.active").focus(); } }); $(".slidesjs-play").on("click",function (event) { if (event.handleObj.type === "click") { $(".slidesjs-stop").focus(); } else if(event.handleObj.type === "keydown"){ if (event.which === 13 && $(event.target).hasClass("slidesjs-play")) { $(".slidesjs-stop").focus(); } } }); $(".slidesjs-stop").on("click",function (event) { if (event.handleObj.type === "click") { $(".slidesjs-play").focus(); } else if(event.handleObj.type === "keydown"){ if (event.which === 13 && $(event.target).hasClass("slidesjs-stop")) { $(".slidesjs-play").focus(); } } }); $(".slidesjs-pagination-item").keydown(function(e){ switch (e.which){ case 37: //left arrow key $(".slidesjs-previous.slidesjs-navigation").trigger('click'); e.preventDefault(); break; case 39: //right arrow key $(".slidesjs-next.slidesjs-navigation").trigger('click'); e.preventDefault(); break; default: return; } $(".slidesjs-pagination-item button.active").focus(); }); }); // Start This code is added by iTalent as part of iTrack 1859082 $(document).ready(function(){ $("#tip1").attr("aria-hidden","true").addClass("hidden"); $("#tip2").attr("aria-hidden","true").addClass("hidden"); $(".slidesjs-stop.slidesjs-navigation, .slidesjs-play.slidesjs-navigation").attr('title', ''); $("a#playtitle").focus(function(){ $("#tip1").attr("aria-hidden","false").removeClass("hidden"); }); $("a#playtitle").mouseover(function(){ $("#tip1").attr("aria-hidden","false").removeClass("hidden"); }); $("a#playtitle").blur(function(){ $("#tip1").attr("aria-hidden","true").addClass("hidden"); }); $("a#playtitle").mouseleave(function(){ $("#tip1").attr("aria-hidden","true").addClass("hidden"); }); $("a#play").keydown(function(ev){ if (ev.which ==27) { $("#tip1").attr("aria-hidden","true").addClass("hidden"); ev.preventDefault(); return false; } }); $("a#stoptitle").focus(function(){ $("#tip2").attr("aria-hidden","false").removeClass("hidden"); }); $("a#stoptitle").mouseover(function(){ $("#tip2").attr("aria-hidden","false").removeClass("hidden"); }); $("a#stoptitle").blur(function(){ $("#tip2").attr("aria-hidden","true").addClass("hidden"); }); $("a#stoptitle").mouseleave(function(){ $("#tip2").attr("aria-hidden","true").addClass("hidden"); }); $("a#stoptitle").keydown(function(ev){ if (ev.which ==27) { $("#tip2").attr("aria-hidden","true").addClass("hidden"); ev.preventDefault(); return false; } }); }); // End This code is added by iTalent as part of iTrack 1859082
Top Kudoed Authors