pardot / ruby-pardot

A Pardot API client written in Ruby

Home Page:http://developer.pardot.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Authentication

mcampo84 opened this issue · comments

I've been receiving errors in my app telling me that username/password authentication is being deprecated, which are preventing me from instantiating an authenticated client. To fix this, I've implemented OAuth JWT bearer flow for server-to-server connections and passed the access_token in to the client constructor thusly:

    client = Pardot::Client.new(nil, nil, nil, 4, access_token, business_unit_id)
    client.authenticate

This causes a RuntimeError:

Authentication not available when using Salesforce access token. See https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/intro_oauth_and_connected_apps.htm for more information.

Either I'm doing something wrong, or no one will be able to authenticate pretty soon.

I'm going to assume I'm doing something wrong with the assumption that the access token is being provided on each API request, and that I don't need to authenticate the client anymore.

As you've discovered, you don't need to call the authentication function since authentication is being handled by Salesforce OAuth before using the Pardot client. The only thing need to use the Pardot client now is to the token from the OAuth "dance".

Here's a full working example if you need.