Expand my Community achievements bar.

SOLVED

SSLerror when running Target API with Python

Avatar

Level 3

I'm able to connect and get API responses with an API client (Insomnia).

However, I keep getting an SSL error when trying to do the same with Python. Anyone managed to get it to work without the SSL error or using verify=false?

 

This is the error I get:

 

SSLError: HTTPSConnectionPool(host='mc.adobe.io', port=443): Max retries exceeded with url: /sunlifeassurance/target/activities/ (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])")))

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Are you able to download the cert from https://mc.adobe.io/ and reference to it in the verify param? Not a python expert and not sure what library you are using. 

View solution in original post

7 Replies

Avatar

Correct answer by
Community Advisor

Are you able to download the cert from https://mc.adobe.io/ and reference to it in the verify param? Not a python expert and not sure what library you are using. 

Avatar

Level 3
I'm able to download the public cert and private key but I'm stuck there as to what to do next. Unfortunately, I am not a python expert either, just started with Spyder (Python 3.7)

Avatar

Community Advisor
Are you using import requests ? If so, requests.get("https://...", verify='my_trust_store.pem')

Avatar

Level 3
I'm guessing I'd have to convert the public cert to a .pem file?

Avatar

Community Advisor
I am pretty sure it would accept a .cer local location. https://requests.readthedocs.io/en/master/user/advanced/ take look at Client Side Certificates.

Avatar

Level 4

I don't have scripts that I run with Adobe often enough to not have to research this each time I do it; see below for the process that I noted for myself next time I had to run the script. I did find working with the Postman templates that they share quite helpful: https://developers.adobetarget.com/api/#admin-postman-collection:~:text=Admin%20Postman%20Collection...

 

Steps to get the access token:
> 1. Find private key: /file-path-to-key/private.key
>> Note that if you don't have private key that is still valid, you'll need to get a new one here:
>> https://helpx.adobe.com/marketing-cloud-core/kb/adobe-io-authentication-step-by-step.html
> 2. Generate JWT token with private key:
>> https://console.adobe.io/projects/xxx/xxxx/credentials/xxxx/details
> 3. Use postman to generate access token:
>> https://www.adobe.io/authentication/auth-methods.html#exchanging-jwt-to-retrieve-an-access-token:~:text=Exchanging%20JWT%20to%20retrieve%20an%20access%20token,-To