I am currently having trouble to finish my python code.
I want to invite external partners to my azure enviroment, but couldnt find any documentation on my specific problem.
# Microsoft Graph
app = ConfidentialClientApplication(
client_id=client_id,
client_credential=client_secret,
authority=f'https://login.microsoftonline.com/{tenant_id}'
)
# obtain an access token for the B2B invitation API
scopes = ['https://graph.microsoft.com/.default']
result = app.acquire_token_silent(scopes=scopes, account=None)
if not result:
result = app.acquire_token_for_client(scopes=scopes)
access_token = result['access_token']
# create the invitation object
invitation = {
'invitedUserDisplayName': first_name + " " +last_name,
'invitedUserEmailAddress': email,
'givenName': first_name,
'surname': last_name,
'companyName': company,
'usageLocation': country,
'inviteRedirectUrl': 'https://tenant.sharepoint.com/',
'sendInvitationMessage': True,
'invitedUserMessageInfo': {
'customizedMessageBody': 'Hi {email_adress}, you can find more information here: https://www.eliostruyf.com'
}
}
try:
response = requests.post(
'https://graph.microsoft.com/beta/invitations',
headers={
'Authorization': 'Bearer ' + access_token,
'Content-Type': 'application/json'
},
json=invitation
)
response.raise_for_status() # check if the response contains an HTTP error status code (4xx or 5xx)
print(response.json())
except requests.exceptions.HTTPError as errh:
print("HTTP Error:", errh)
except requests.exceptions.ConnectionError as errc:
print("Error Connecting:", errc)
except requests.exceptions.Timeout as errt:
print("Timeout Error:", errt)
except requests.exceptions.RequestException as err:
print("Something went wrong:", err)
This coud is designed to user fields of a Jira Ticket, where the (email, first_name, last_name, company, country) are populated. Thies fields are pulled from the Api amd with the code shown below should be proccessed further.
Now to my specific problem, I couldnt find any documentation on how to parse the Company and Usage Location (Country) to Microsoft Graph Invitation.
Does anyone have expirience with this or is it simpley not possible with Microsoft Graph?
Thank you for you time and help in advance.
Friendly Greetings Michael
I was expected to have a External Guest User in Azure with all fields populated, this worked for first_name, last_name, email, Invitation email and so on. But unfortunately not for the country and company.