I am using gmail login as one of the ways to log in. I tried to update the nickname and I got a message to read this link: Configure Identity Provider Connection for User Profile Updates. After reading the link, I was able to get the options object as the page suggested. The issue I’m having is actually sending the update value. Here is my code pasted below.
access_token = token_data.get("access_token")
url = f"https://{os.getenv('AUTH0_DOMAIN')}/api/v2/connections/{os.getenv('AUTH0_GOOGLE_CONNECT_ID')}?fields=options"
headers = { 'Authorization': f"Bearer {access_token}" }
response = requests.request("GET", url=url, headers=headers, data={})
options = response.json()
options["options"]["set_user_root_attributes"] = {}
options["options"]["set_user_root_attributes"]["nickname"] = "testing123"
print(options)
url = f"https://{os.getenv('AUTH0_DOMAIN')}/api/v2/connections/{os.getenv('AUTH0_GOOGLE_CONNECT_ID')}"
headers = {
'content-type': "application/json",
'authorization': f"Bearer {access_token}",
'cache-control': "no-cache"
}
response = requests.request("PATCH", url=url, headers=headers, data = options["options"])
Additionally here is what my options looks like after I modified it to send the update value:
{'id': 'con_0wtNYlyFUgJscY4L', 'options': {'email': True, 'gmail': False, 'orkut': False, 'scope': ['email', 'profile'], 'sites': False, 'tasks': False, 'blogger': False, 'profile': True, 'youtube': False, 'calendar': False, 'contacts': False, 'analytics': False, 'client_id': '', 'moderator': False, 'coordinate': False, 'picasa_web': False, 'google_plus': False, 'google_books': False, 'google_drive': False, 'spreadsheets': False, 'document_list': False, 'latitude_best': False, 'latitude_city': False, 'url_shortener': False, 'webmaster_tools': False, 'chrome_web_store': False, 'allowed_audiences': '', 'adsense_management': False, 'google_drive_files': False, 'coordinate_readonly': False, 'google_cloud_storage': False, 'content_api_for_shopping': False, 'google_affiliate_network': False, 'set_user_root_attributes': {'nickname': 'testing123'}}, 'is_domain_connection': False}
The error I am getting is: “Invalid request payload JSON format”
Thank you in advance.