0

I keep getting an error in the URL stating: https://companyname.my.salesforce.com/_nc_external/identity/sso/ui/AuthorizationError?ErrorCode=CSRF&ErrorDescription=No+CSRF+cookie&ProviderId=0SOOK0000000YGD

DIDN'T WORK: I saw this in a forum as this was being discussed for a sandbox env:

The CSRF issue is being caused by protection inbuilt by Salesforce to prevent security attacks across different domains. This led me to check the 'My Domain' settings in Salesforce. I discovered that I had not enabled My Domain for all users. Try the following in a sandbox:

  1. Going to 'My Domain'
  2. Clicking on 'Deploy to Users'
  3. Now retry logging in from your domain home page
import requests as r
import webbrowser
import os

# get bearer token
pardot_business_unit_id = "0Uv0d000000*******"

# Access Token is being provided by SF Developer
#access_request = r.post(auth_url, params = {'grant_type': 'password','client_id': client_id,'client_secret': client_secret,'username': user_name,'password': password})

# store access token
#access_request.json()['access_token']
access_token = "6Cel***********"

# auth headers
auth_header = {'Pardot-Business-Unit-Id': pardot_business_unit_id,'Authorization': f"Bearer {access_token}"}

# define parameters in export api request
export_params = {"fields": "id,createdAt,status,isExpired,updatedAt,includeByteOrderMark,maxFileSizeBytes"} 

# define payload
pardot_request = r.get(

    url='https://companyname.my.salesforce.com/services/auth/oauth/Pardot_API/api/v5/objects/prospects',

    headers = {

        'Pardot-Business-Unit-Id': pardot_business_unit_id, 

        'Authorization': f"Bearer {access_token}",},

    params = {'fields':'id,firstName,lastName,email'}

)

print(pardot_request.json) #401 Unauthorized

#print(pardot_request.text) 

with open('temp.html', 'w') as f:
    f.write(pardot_request.text)

webbrowser.open('file://' + os.path.realpath('temp.html'))
1

0

You must log in to answer this question.

Browse other questions tagged .