Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Use pip:
pip install py-msgraph
or
pip install git+https://github.com/shineum/py_msgraph.git
To use MS graph API, MS application is necessary and tenant_id, client_id and client_secret are prepared. It is needed to assign the permissions in the MS application depending on the APIs.
Here are reference URLs.
# Set up a Tenant
https://learn.microsoft.com/en-us/azure/active-directory/develop/quickstart-create-new-tenant
# Register an application
https://learn.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-app
# Graph API Permissions
https://learn.microsoft.com/en-us/graph/permissions-reference
Initialize MSGraphServiceClient instance.
from py_msgraph import MSGraphServiceClient
config = {
'tenant_id': '<tentant_id>',
'client_id': '<client_id>',
'client_secret': '<client_secret>'
}
client: MSGraphServiceClient = MSGraphServiceClient(config)
To get data, use "get_data" method.
data = client.get_data('<api_name>', '<options - optional>', '<version: api version - optional>')
ex)
data = client.get_data('users', {'$filter': "userPrincipalName eq 'youremail@yourdomain.com'", '$select': 'id'})
print(data)
To send post request, use "post_data" method.
result = client.post_data('<api_name>', '<data: request body - optional>', '<headers: headers - optional>', '<version: api version - optional>', '<files: attachment - optional>')
ex)
user_id = "<user guid>"
group_id = "<group guid>"
req_body = {
"@odata.id": f"https://graph.microsoft.com/v1.0/users/{user_id}"
}
result = client.post_data(f"groups/{group_id}/members/$ref", req_body)
print(result)
This library also support put, patch and delete methods.
result = client.put_data('<api_name>', '<data: request body - optional>', '<headers: headers - optional>', '<version: api version - optional>', '<files: attachment - optional>')
result = client.patch_data('<api_name>', '<data: request body - optional>', '<headers: headers - optional>', '<version: api version - optional>', '<files: attachment - optional>')
result = client.delete_data('<api_name>', '<data: request body - optional>', '<headers: headers - optional>', '<version: api version - optional>', '<files: attachment - optional>')
FAQs
library to use MS graph API
We found that py-msgraph demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.