How to set custom authorization header in request section of logic app custom connector without use Security Tab.

Mehul Bhuva 0 Reputation points
2025-05-29T11:12:01.12+00:00

While developing a Custom Connector for API calls that use Bearer tokens for authorization like header : "Authorization: Bearer access_token". Currently, we can set custom authorization headers in the connector actions and retrieve the authorization key using API Key authentication. However, our tokens expire every 30 minutes, requiring users to manually update the token in the Logic Apps API Connection. We're aiming to improve this process by:

  • Creating a specific action for generating tokens.
  • Automatically using the generated token in subsequent custom actions.

Is there any way to achieve this task?

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
3,542 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Sina Salam 22,031 Reputation points Volunteer Moderator
    2025-05-29T16:13:09.14+00:00

    Hello Mehul Bhuva,

    Welcome to the Microsoft Q&A and thank you for posting your questions here.

    I understand that you are enquiring on how you can set custom authorization header in request section of logic app custom connector without use Security Tab.

    Yes, you can streamline the token management process in a Custom Connector for Logic Apps or Power Automate/Power Apps by implementing a token refresh mechanism. But you cannot set a custom Authorization header in the request section of a Logic App Custom Connector without using the Security tab.

    • This is a platform limitation.
    • The only viable workaround is to use HTTP actions in Logic Apps, where you can dynamically set headers, including Bearer tokens.

    Putting into consideration that:

    • Using Custom Connector with API Key auth for Bearer tokens — not dynamic.
    • Trying to inject Authorization header in Custom Connector — not allowed.
    • And since Custom Connectors have limitations, the best approach is to avoid using them for token-based APIs and instead use HTTP actions in Logic Apps.

    Therefore, the best practice is that:

    • Use HTTP action with client credentials for Token Generation.
    • Use Logic App variables or Azure Key Vault for Token Storage.
    • Use HTTP action with dynamic Authorization header for API Calls.
    • Avoid using Custom Connector for dynamic Bearer tokens.

    If you would like to implement as stated, the below are the high-level steps and option you can take:

    • Use an HTTP action to call the token endpoint using Client Credentials Flow.
        POST https://your-auth-server.com/oauth2/token
        Content-Type: application/x-www-form-urlencoded
        client_id=your_client_id&
        client_secret=your_client_secret&
        grant_type=client_credentials
      
    • Use a "Parse JSON" action to extract the access_token and store it in a Logic App variable.
    • Thirdly, use another HTTP action to call your API, and set the Authorization header dynamically in http: Authorization: Bearer @{variables('access_token')}
    • Add logic to check if the token is expired (if expiry time is returned), or simply regenerate the token before each run.
    • Optional to use Azure Key Vault, store the token securely in Azure Key Vault and retrieve it when needed.

    I hope this is helpful! Do not hesitate to let me know if you have any other questions or clarifications.


    Please don't forget to close up the thread here by upvoting and accept it as an answer if it is 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.