Reputation: 1047
I am using the below code to read response from an api. I am stuck with how to encrypt credentials. I get invalid syntax error.
import requests
from base64 import b64encode
user = "usr"
password = "pwd"
response = requests.get('https://myapi/v1/api',
auth=(user, password) # invalid syntax
data = response.json()
Upvotes: 0
Views: 113
Reputation: 5359
You are missing a parenthesis in this line at the end:
response = requests.get('https://myapi/v1/api', auth=(user, password))
Upvotes: 1
Reputation: 83567
I am using the below code to read response from an api. I am stuck with how to encrypt credentials.
https
already encrypts the request, so you don't need to do anything special here.
I get invalid syntax error.
You get this error because you are missing a closing parenthese.
Upvotes: 0