Power Query Obtener token para OAUTH

Un usuario Pregunto ✅

marioboehme

Hola a todos,

Tengo el siguiente código para generar un token OAUTH. ¿Alguien tiene idea de cómo escribo esto en Power Query?

// Values from your OAuth app. You create ONE for a page/plugin/service.
$clientid     = "#Place OAuth clientID here#";
$clientsecret = "#Place OAuth client secret here#";

// The official CleverReach URL, no need to change this.
$token_url = "https://rest.cleverreach.com/oauth/token.php";

// We use curl to make the request
$curl = curl_init();
curl_setopt($curl,CURLOPT_URL, $token_url);
curl_setopt($curl,CURLOPT_USERPWD, $clientid . ":" . $clientsecret);
curl_setopt($curl,CURLOPT_POSTFIELDS, array("grant_type" => "client_credentials"));
curl_setopt($curl,CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($curl);
curl_close ($curl);

// The final $result contains the access_token and some other information besides.
// For you to see it, we dump it out here.
var_dump($result);

El resultado final del proceso de OAuth es el token de acceso. Este es el formato de la respuesta como ejemplo.

{
  "access_token":  "7h4t1s50mek1nd0fab4t70ken",
  "expires_in":    31536000,
  "scope":         "batmobile batcycle batplane batcopter",
  "refresh_token": "m4keb4t70kenfr35h"
}

Stachu

tener una lectura aquí:
https://community.powerbi.com/t5/Desktop/Issue-with-getting-data-via-API-with-bearer-token/mp/12623…
y aquí
https://community.powerbi.com/t5/Desktop/Power-Query-Open-ID-and-OAuth-2-0-Rest-API/mp/693162

marioboehme

En respuesta a Stachu

@Stachu Gracias por los enlaces, pero desafortunadamente no puedo llegar a ningún lado con ellos, porque el proceso cURL para la solicitud no se explica aquí. ¿Tienes una idea de cómo escribo esto con PowerQuery?

Stachu

En respuesta a marioboehme

intente conectarse con la interfaz de usuario de PowerBI (conexión web regular) y muestre el código M que se genera junto con los errores respectivos, intentaré solucionar el problema desde allí

marioboehme

En respuesta a Stachu

He insertado la URL del token solo en Web Connection sin configuraciones y aparece este mensaje.Anmerkung 2020-02-18 120224.png

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *