Giter Site home page Giter Site logo

Comments (7)

j-douglas-tf avatar j-douglas-tf commented on July 19, 2024 2

You'll need to switch to a different way of doing your CURL - the documentation tells you to switch, but doesn't tell you WHAT to do instead - this is what i've written, and it's working for me!

$curl = curl_init();

	curl_setopt_array( $curl, array(
		CURLOPT_URL            => $this->url,
		CURLOPT_RETURNTRANSFER => true,
		CURLOPT_ENCODING       => "",
		CURLOPT_MAXREDIRS      => 10,
		CURLOPT_TIMEOUT        => 30,
		CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
		CURLOPT_CUSTOMREQUEST  => "POST",
		CURLOPT_POSTFIELDS     => 'email='.$this->email.'&password='.$this->password.'&user_key='.$this->user_key,
		CURLOPT_HTTPHEADER     => array(
			"cache-control: no-cache",
			"content-type: application/x-www-form-urlencoded",
		)
	));

	$response = curl_exec($curl);
	$err = curl_error($curl);

	curl_close($curl);

	$xml  = new SimpleXMLElement( $response );
	$obj  = $xml->api_key;
	$key  = (string) $obj{0};
	return $key;

from api-docs.

Art-em1s avatar Art-em1s commented on July 19, 2024

From their support:

First of all, please note you need to use the version 4 for all your calls as you have AMPSEA enabled (https://help.salesforce.com/articleView?id=pardot_admin_ampsea_parent.htm&type=5).

Also, there was a change made on the 14th of February that means you will no longer be able to authenticate with the Pardot API using an HTTP authorisation header, which essentially translates to not being able to authenticate with the Pardot API using your credentials in the URL/header.

For example, you will no longer be able to authenticate with Pardot and generate an API key using the following method:

https://pi.pardot.com/api/login/version/[email protected]&password=XXXXXXXXX&user_key=XXXXXXX

You would need to have your credentials as parameters in the body of the API request, as mentioned in the Pardot API documentation below:

http://developer.pardot.com/#authentication

Something to note, the method stated doesn't work and their API documentation that they link to says something completely different.

from api-docs.

Art-em1s avatar Art-em1s commented on July 19, 2024

Interestingly, the above works in postman, but not in php, returning "Login Failed".

from api-docs.

muralib36 avatar muralib36 commented on July 19, 2024

You'll need to switch to a different way of doing your CURL - the documentation tells you to switch, but doesn't tell you WHAT to do instead - this is what i've written, and it's working for me!

$curl = curl_init();

	curl_setopt_array( $curl, array(
		CURLOPT_URL            => $this->url,
		CURLOPT_RETURNTRANSFER => true,
		CURLOPT_ENCODING       => "",
		CURLOPT_MAXREDIRS      => 10,
		CURLOPT_TIMEOUT        => 30,
		CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
		CURLOPT_CUSTOMREQUEST  => "POST",
		CURLOPT_POSTFIELDS     => 'email='.$this->email.'&password='.$this->password.'&user_key='.$this->user_key,
		CURLOPT_HTTPHEADER     => array(
			"cache-control: no-cache",
			"content-type: application/x-www-form-urlencoded",
		)
	));

	$response = curl_exec($curl);
	$err = curl_error($curl);

	curl_close($curl);

	$xml  = new SimpleXMLElement( $response );
	$obj  = $xml->api_key;
	$key  = (string) $obj{0};
	return $key;

Now it is working fine Thanks.

from api-docs.

 avatar commented on July 19, 2024

Authentication is documented in the developer documentation. This source repository is for the documentation and is not a channel for support. If you need assistance or help with Pardot, please contact Pardot Support.

from api-docs.

dattajoshi avatar dattajoshi commented on July 19, 2024

From their support:

First of all, please note you need to use the version 4 for all your calls as you have AMPSEA enabled (https://help.salesforce.com/articleView?id=pardot_admin_ampsea_parent.htm&type=5).
Also, there was a change made on the 14th of February that means you will no longer be able to authenticate with the Pardot API using an HTTP authorisation header, which essentially translates to not being able to authenticate with the Pardot API using your credentials in the URL/header.
For example, you will no longer be able to authenticate with Pardot and generate an API key using the following method:
https://pi.pardot.com/api/login/version/[email protected]&password=XXXXXXXXX&user_key=XXXXXXX
You would need to have your credentials as parameters in the body of the API request, as mentioned in the Pardot API documentation below:
http://developer.pardot.com/#authentication

Something to note, the method stated doesn't work and their API documentation that they link to says something completely different.

@Art-em1s Did you have any luck on this? I'm trying the same way, but in Python. It's working only if the Content-type is "application/x-www-form-urlencoded", but if it's JSON it's failing.

from api-docs.

 avatar commented on July 19, 2024

@dattajoshi

If you are using the "requests" module:

import requests, json

userKey = '<user_key>'
password = '<password>'
email = '<email>'

r = requests.post('https://pi.pardot.com/api/login', params = {'format': 'json'}, data = {'user_key': userKey, 'email': email, 'password': password})
j = json.loads(r.text)
print(j['api_key'])

If you are using the standard Python 3 libraries:

import http.client, urllib.parse, json

userKey = '<user_key>'
password = '<password>'
email = '<email>'

params = urllib.parse.urlencode({'user_key': userKey, 'email': email, 'password': password});
headers = {"Content-type": "application/x-www-form-urlencoded"}

conn = http.client.HTTPSConnection('pi.pardot.com')
conn.request('POST', '/api/login?format=json', params, headers)
response = conn.getresponse()
data = response.read()
conn.close()

j = json.loads(data)
print(j['api_key'])

from api-docs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.