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_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(


    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


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

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


You must log in to answer this question.

Browse other questions tagged .