0

I'm developing a Logic app that should call a specific API one time for a day to retrieve the response (a token) and on the next steps (not already written) it will contact another API and finally it will store the result on a Google spreadsheet. The problem is on the first call, reading the documentation of MailUp I must send a call to an URL to retrieve the token using username e password authentication ( https://help.mailup.com/display/mailupapi/Authenticating+with+OAuth+v2 ) but it doesn't work! Can someone help me?

{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "HTTP": {
                "inputs": {
                    "headers": {
                        "Authorization": "BASE64_ENCODED_CLIENTCREDENTIALS",
                        "Content-Type": "application/x-www-form-urlencoded"
                    },
                    "method": "POST",
                    "queries": {
                        "grant_type": "password",
                        "password": "password",
                        "username": "username"
                    },
                    "uri": "https://services.mailup.com/Authorization/OAuth/Token"
                },
                "runAfter": {
                    "Initialize_variable": [
                        "Succeeded"
                    ]
                },
                "type": "Http"
            },
            "Initialize_variable": {
                "inputs": {
                    "variables": [
                        {
                            "name": "responseBody",
                            "type": "String",
                            "value": ""
                        }
                    ]
                },
                "runAfter": {},
                "type": "InitializeVariable"
            },
                "type": "ApiConnection"
            },
            "Set_variable": {
                "inputs": {
                    "name": "responseBody",
                    "value": "@{body('HTTP')}"
                },
                "runAfter": {
                    "HTTP": [
                        "Succeeded"
                    ]
                },
                "type": "SetVariable"
            }
        },
        "contentVersion": "1.0.0.0",
        "outputs": {},
        "parameters": {
            "$connections": {
                "defaultValue": {},
                "type": "Object"
            }
        },
        "triggers": {
            "Recurrence": {
                "evaluatedRecurrence": {
                    "frequency": "Day",
                    "interval": 1
                },
                "recurrence": {
                    "frequency": "Day",
                    "interval": 1
                },
                "type": "Recurrence"
            }
        }
    },
    "parameters": {
        "$connections": {
            "value": {
            }
        }
    }
}
Skin
  • 9,085
  • 2
  • 13
  • 29
Filippo1980
  • 2,745
  • 5
  • 30
  • 44

1 Answers1

1

Due to access issues, I will not be able to use https://help.mailup.com/display/mailupapi/Authenticating+with+OAuth+v2 here but I will use https://login.microsoft.com/{tenant_id}/oauth2/token to generate bearer token in the same way you are trying to generate them in logic app.

enter image description here

Try to structure the body in the following format like use '&' instead of 'comma' in your case. Use clientId and client_password too along with the username and password. Here I am taking below inputs to generate token:

URL https://login.microsoft.com/{tenant_id}/oauth2/token

Headers Content-Type: application/x-www-form-urlencoded

Body grant_type=password&resource=https://graph.microsoft.com&client_id=<your client ID>&client_secret=<your client secret>&username=<username>&password=<password>

enter image description here

Output

enter image description here

enter image description here

If you refer the above steps, you will be able to generate access token and refresh token too.

Ikhtesam Afrin
  • 897
  • 1
  • 1
  • 6