Mattias
Mattias

Reputation: 70

Azure Logic App throwing 302 Redirect Error

I am getting redirect 302 error for my HTTP request in my logic app.

The scenario is that I have a logic app where I want to fetch data from an API endpoint. The API endpoint is protected and I need to provide an access token to be able to access the api.

To be able to connect to the API with an access token I have created an service principal in Azure AD (spn) to use in the logic app.

The logic app contains right now of two HTTP actions:

with client_id, client_secret and tenant_id of the service principal to get an access token which I can use to authenticate against the API.

but I only get 302 Redirect as response.

I have verified that everything is working as expected with Postman with the same requests as explained above.

Any ideas on how to get around this issue?

Redirect screenshot

Logic App workflow

Upvotes: 0

Views: 3079

Answers (1)

Mattias
Mattias

Reputation: 70

I've found the cause of this issue. It was in fact something wrong with the token, the logic app successfully acquired the Bearer token, however, However, in the POST request against : https://login.microsoftonline.com/tenantId/oauth2/token

I had specified the following:

grant_type=client_credentials
&client_id=<clientId>
&client_secret=<clientSecret>
&resource=https://something.com <- (HERE I forgot an "/")

I found this when I tried using the token aquired in the logic app in postman and it returned a redirect and invalid token. Thanks for the help all.

Upvotes: 1

Related Questions