0

I did it the postman like the following steps

  • In the authorization tab, I selected OAuth 2.0 as Type.
  • Then clicked on get new access token.

  • I selected grant type as Client Credentials. Added access token url, client id and client secret and generated token.

  • And then used that toke using the api call to get the results.

So How will I do this feeds importer? I have a custom fetcher which has the getRaw method. I have to do this in that function? and how?

I have no idea how to do this so I didn't try any code.

I have tried the feeds_oauth module, but it has some extra fields like site id, authorization url which I don't know what to put there.

Update:

The feeds_oauth module only work with grant type authorization code. And I am using the grant type client credentials.

If I have the following code to get the access toke:

    $content = "grant_type=client_credentials";
    $authorization = base64_encode("$client_id:$client_secret");
    $header = array("Authorization: Basic {$authorization}","Content-Type: application/x-www-form-urlencoded");

    $curl = curl_init();
    curl_setopt_array($curl, array(
        CURLOPT_URL => $token_url,
        CURLOPT_HTTPHEADER => $header,
        CURLOPT_SSL_VERIFYPEER => false,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_POST => true,
        CURLOPT_POSTFIELDS => $content
    ));
    $response = curl_exec($curl);
    curl_close($curl);

    $access_token = json_decode($response)->access_token;

How can I then use this token with the feeds api url where I have to send the request?

Is it will be like this

  public function getUrl() {
    return $this->url . '?access_token=' . $access_token;
  }

in my custom fetcher?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.