Unable to make an api call to a whitelist method using user api secret and key

getting error “checking_frappe_api” is not whitelisted

even though the function is whitelisted
image

i am using correct api key and secret but still why getting this issue?

Hi @Vinay1:

Use Basic apikey:apisecret on authorization.
apikey:apisecret should be Base64 encoded.

Hope this helps.

hey @avc, making apikey:apisecret as Base64 encoded and using Basic apikey:apisecret on authorization worked perfectly.

here is the updated code

import base64
import requests

# Replace with your actual API credentials
api_key = 'api_key'
api_secret = 'api_secret'

# Combine the API key and secret
credentials = f"{api_key}:{api_secret}"

# Encode the credentials in Base64
encoded_credentials = base64.b64encode(credentials.encode('utf-8')).decode('utf-8')

# Set up the headers with the Basic Authentication
headers = {
    'Authorization': f'Basic {encoded_credentials}',
    'Content-Type': 'application/json'
}

# Define the API endpoint
url = 'http://127.0.0.1:8000/api/method/pcvn.pcvn.doctype.membership.membership.checking_frappe_api'

# Make the GET request
response = requests.get(url, headers=headers)

# Print the response
print("Response: ",response)
print(f"Status Code: {response.status_code}")
print(f"Response Body: {response.text}")