Passing the secret scope to the url

SrinMand_34861
New Contributor II

We are trying to call an URL by using the credentials,

we are able to get the data when we hard code the credentials.

Not returning any data when we pass the secret scope credentials.

below is the code.

import requests

source_db_scope = "dev-hnd-secret-scope"

source_user_name_secret = "username"

source_password_secret = "password"

username = dbutils.secrets.get(scope = source_db_scope, key = source_user_name_secret)

password = dbutils.secrets.get(scope = source_db_scope, key = source_password_secret)

url = "http://abc.com:8000/scheduler_etl.xsjs"

response = requests.get(url,auth=(username ,password ))

Can you please suggest. Appreciate your help

Thanks

Srini

Hubert-Dudek
Databricks MVP

please try to debug what secret scope is returning. The ugly way to do it is:

for letter in username:

print(letter, ' ')


My blog: https://databrickster.medium.com/

Secret scope masks the value and returns [Redacted] for both username and password.

try

for letter in username:
    print(letter, end=" "')
    print("\n")


My blog: https://databrickster.medium.com/

I'm able to print the credentials and they are correct.