Failed to get access token from your token endpoint. Error message: No MediaTypeFormatter is available to read an object of type 'OAuth2AccessToken' from content with media type 'text/html

Josh Starita 0 Reputation points
2024-05-29T16:36:57.1933333+00:00

In Azure Data Factory I am trying to connect to a REST API that uses OAuth 2.0 Authentication. When supplying Data Factory with all the necessary credentials and testing the connection I get the error:

Failed to get access token from your token endpoint. Error message: No MediaTypeFormatter is available to read an object of type 'OAuth2AccessToken' from content with media type 'text/html'

I can't find a good solution to this error. Does this mean that ADF can't handle the format that the bearer token is coming in as? Any help is appreciated. Thanks!

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,137 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Harishga 5,995 Reputation points Microsoft Vendor
    2024-05-30T05:44:36.5333333+00:00

    Hi @Josh Starita
    Welcome to Microsoft Q&A platform and thanks for posting your question here.

    According to the REST connector documentation, the supported authentication types are Anonymous, Basic, AadServicePrincipal, and ManagedServiceIdentity. User-based OAuth authentication is not supported.User's image

    You can use the Web activity to make an API call and get the bearer token. You can then pass this token from the Web activity output JSON to the main API call to perform the desired work.

    According to the thread, outh2 isn't directly supported in the linked service, but documentation still mentions wrongly. We will follow up with the PG team to correct the documentation, in the meantime, you can refer to this Microsoft Q&A thread for more information on using OAuth2 with Data Factory Linked Service REST.

    Reference
    https://stackoverflow.com/questions/70081302/using-oauth2-0-in-web-activity-in-azure-data-factory
    https://learn.microsoft.com/en-us/answers/questions/741180/data-factory-linked-service-rest-oauth2

    https://learn.microsoft.com/en-us/answers/questions/52665/how-can-we-authenticate-rest-api-endpoint-via-api

    Hope this helps. Do let us know if you any further queries.


    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.