Config App Registration for Sharepoint API.pptx

NorasetKrudsamai 19 views 8 slides Jul 19, 2024
Slide 1
Slide 1 of 8
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8

About This Presentation

Config App Registration for Sharepoint API.pptx


Slide Content

How to config API SharePoint for application.

Register an Application in Azure AD Sign in to Azure Portal Navigate to Microsoft Entra ID Register a New Application In the Microsoft Entra ID pane, select "App registrations" and then click on "New registration."

Register an Application in Azure AD Provide a name for your application (e.g., "GCP-SharePoint Integration"). Choose an account type. Typically, "Accounts in any organizational directory". Under "Redirect URI," select "Web" and enter a placeholder URI (e.g., https://localhost), which you can modify later if needed. Click "Register" to create the application.

Configure API Permissions After registering the application, you will be redirected to the app's overview page. In the left-hand menu, select "API permissions" and then click “Add a permission.” Select “Microsoft Graph.” Select “Application Permissions” Choose the permissions your application needs. For example: Sites.ReadWrite.All Files.Read.All Directory.Read.All Click "Add permissions.“ Click on the "Grant admin consent for [Your Organization]" button and confirm the action

Generate Client Secret In the left-hand menu, select “Certificates & secrets.” Under "Client secrets," click on "New client secret.“

Generate Client Secret In the left-hand menu, select “Certificates & secrets.” Under “Client secrets,” click on "New client secret.” Provide a description (e.g., "GCP-SharePoint Secret") and set an expiration period. Click "Add" to create the secret.

Provide information required to access SharePoint Tenant ID Client ID Client Secret Use these credentials as information to test connect to SharePoint

Python code snippet to test connect sharepoint import requests from google . cloud import storage import json # Replace with your Azure AD credentials TENANT_ID = ‘’ CLIENT_ID = ‘’ CLIENT_SECRET = ‘’ # Replace with your SharePoint site details SITE_ID = ‘’ LIST_ID = ‘’ # Obtain OAuth2 token from Azure AD token_url = f'https ://login.microsoftonline.com/{ TENANT_ID }/oauth2/v2.0/token’ payload = { ' grant_type ' : ' client_credentials ’ , ' client_id ' : CLIENT_ID , ' client_secret ' : CLIENT_SECRET , 'scope' : 'https://graph.microsoft.com/.default’ } token_response = requests . post ( token_url , data = payload ) token = token_response . json (). get ( ' access_token ’ ) # Use the token to access SharePoint data headers = { 'Authorization' : f'Bearer { token }' , 'Accept' : 'application/ json ’ } # Example: Get items from a SharePoint list api_url = f'https ://graph.microsoft.com/v1.0/sites/{ SITE_ID }/lists/{ LIST_ID }/items’ response = requests . get ( api_url , headers = headers ) data = response . json () print ( json . dumps ( data , indent = 2 ))