Add new attachment

Only authorized users are allowed to upload new attachments.

List of attachments

Kind Attachment Name Size Version Date Modified Author Change note
png
app_permission_sharepoint_site... 198.2 kB 1 29-Apr-2025 11:24 krivacsz
png
app_permission_sites_full_cont... 159.9 kB 1 29-Apr-2025 09:55 krivacsz
png
check_new_permission.png 112.3 kB 1 30-Apr-2025 07:45 krivacsz
png
check_response_code.png 118.7 kB 1 29-Apr-2025 16:31 krivacsz
png
error_handler_task.png 91.2 kB 1 30-Apr-2025 07:44 krivacsz
png
find_a_file.png 116.5 kB 1 29-Apr-2025 16:00 krivacsz
png
get_acccess_token_variables.pn... 121.1 kB 2 30-Apr-2025 05:41 krivacsz
png
get_access_token_http_1.png 121.5 kB 1 29-Apr-2025 16:08 krivacsz
png
get_access_token_http_2.png 46.3 kB 1 29-Apr-2025 16:12 krivacsz
png
get_site_permission_http_1.png 109.0 kB 1 29-Apr-2025 16:27 krivacsz
png
get_site_permission_http_2.png 45.5 kB 1 29-Apr-2025 16:29 krivacsz
png
grant_sharepoint_site_access_j... 249.2 kB 3 30-Apr-2025 07:18 krivacsz
xml
job.XML 47.3 kB 1 01-May-2025 04:57 krivacsz
png
new_permission_http_1.png 116.3 kB 1 30-Apr-2025 07:03 krivacsz
png
new_permission_http_2.png 51.7 kB 1 30-Apr-2025 07:09 krivacsz
png
new_permission_related_variabl... 125.4 kB 1 30-Apr-2025 06:59 krivacsz
png
parse_access_token_from_respon... 86.0 kB 2 30-Apr-2025 06:18 krivacsz
png
site_selected_microsoft_graph.... 170.2 kB 1 30-Apr-2025 02:38 krivacsz

This page (revision-114) was last changed on 01-May-2025 04:59 by krivacsz

This page was created on 29-Apr-2025 08:00 by krivacsz

Only authorized users are allowed to rename pages.

Only authorized users are allowed to delete pages.

Difference between version and

At line 3 changed one line
The __Sites.Selected__ permission allows an app to access only the specific SharePoint sites you explicitly authorize. This wiki page provides guidance on how to grant SharePoint write access (required for __SharePoint2 protocol__ see [SharePoint Integration]) to an __App Registration__ configured in the Azure Portal. Using Sites.Selected offers a much more secure alternative to granting full access across your entire tenant. See this: [https://learn.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azuread]\\
The __Sites.Selected__ permission allows an app to access only the specific SharePoint sites you explicitly authorize. This wiki page provides guidance on how to grant SharePoint write access (required for __SharePoint__/__SharePoint2 protocol__ see [SharePoint Integration]) to an __App Registration__ configured in the Azure Portal. Using Sites.Selected offers a much more secure alternative to granting full access across your entire tenant. See this: [https://learn.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azuread]\\
At line 12 changed one line
__Application registration: __Go to the App registrations and click on __New registration__:\\
__Application registration:__ Navigate to App registrations in the Azure Portal. Click on __New registration__ to create a new application.\\
At line 18 changed one line
Configure API Permissions:\\
__Configure API Permissions__: Navigate to API Permissions. Click on __Add a permission__ button. Select __Microsoft Graph__. Then select __Application Permission__. Search for __Sites__ and check the flag __Sites.FullControll.All__.\\
At line 20 removed 2 lines
Navigate to API Permissions. Click on __Add a permission__ button. Select __Microsoft Graph__. Then select __Application Permission__. Search for __Sites__ and check the flag __Sites.FullControll.All__.\\
\\
At line 22 added 4 lines
Grant __Admin consent__ for the newly added permission.\\
\\
[SharePoint Integration/app_permission_admin_consent.png]\\
\\
At line 30 changed one line
!!__2.__ Create an App Registration to Access SharePoint Site Documents Using the Sites.Selected Permission\\
!!__2.__ Create an App Registration to Access Specific SharePoint Site Documents Using the Sites.Selected Permission\\
At line 41 changed one line
Navigate to API Permissions. Click on Add a permission button. Select SharePoint. Then select Delegated Permission. Search for Sites and check the flag Sites.Selected.
Navigate to API Permissions. Click on Add a permission button. Select SharePoint or Microsoft Graph. Then select Delegated/Application Permission. Search for Sites and check the flag Sites.Selected.\\
At line 45 added 2 lines
__2.1 App Permissions for SharePoint REST API__ (See at: [https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/get-to-know-the-sharepoint-rest-service?tabs=csom]):\\
\\
At line 49 added 4 lines
__2.2 App Permissions for Microsoft Graph API__ (See at: [https://learn.microsoft.com/en-us/sharepoint/dev/apis/sharepoint-rest-graph]):\\
\\
[CrushTaskExample19/site_selected_microsoft_graph.png]\\
\\
At line 47 changed one line
To grant Site Access for App registration you need to do an HTTPS call:\\
!!! 3. How to Grant SharePoint Site Access to an App Registration Using the Microsoft Graph API?\\
\\
This is done by calling the __/permissions__ endpoint on the target SharePoint site. The request must include a valid Microsoft Graph access token with __Sites.FullControl.All__ application permission, and specify the App Registration you want to grant access to using the application.id in the request body:\\
At line 60 added 12 lines
BODY: {
"roles": ["write"],
"grantedToIdentities": [
{
"application": {
"id": "11111111-2222-3333-4444-555555555555",
"displayName": "My Azure App Registration"
}
}
]
}
At line 52 changed one line
CURL example:\\
__Curl example__:\\
At line 55 changed one line
curl -X POST "https://graph.microsoft.com/v1.0/sites/contoso.sharepoint.com:/sites/Marketing:/permissions" \
curl -X POST "https://login.microsoftonline.com/<<App Registration: Directory (tenant) ID>>/oauth2/v2.0/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "client_id=XXX-XXXX-XXX-XX&scope=https%3A%2F%2Fgraph.microsoft.com%2F.default&client_secret=XXX-XXXX-XXX-XX&grant_type=client_credentials"
}}}\\
\\
{{{
curl -X POST "https://graph.microsoft.com/v1.0/sites/contoso.sharepoint.com:/sites/Your_Site:/permissions" \
At line 64 changed one line
"displayName": "My Azure App"
"displayName": "My Azure App Registration"
At line 69 changed one line
}}}
}}}\\
At line 71 changed one line
!!!3. Job\\
__PowerShell example__:\\
{{{
$tenantId = "<<your-tenant-id>>" # Directory (tenant) ID
$clientId = "XXX-XXXX-XXX-XX" # App Registration (client ID)
$clientSecret = "XXX-XXXX-XXX-XX" # Client secret
$tokenEndpoint = "https://login.microsoftonline.com/$tenantId/oauth2/v2.0/token"
$body = @{
client_id = $clientId
scope = "https://graph.microsoft.com/.default"
client_secret = $clientSecret
grant_type = "client_credentials"
}
$response = Invoke-RestMethod -Method POST -Uri $tokenEndpoint -Body $body -ContentType "application/x-www-form-urlencoded"
# Output access token
$accessToken = $response.access_token
Write-Host "Access Token:" $accessToken
}}}\\
At line 121 added 31 lines
{{{
$accessToken = "YOUR_ACCESS_TOKEN"
$sitePath = "contoso.sharepoint.com:/sites/Your_Site:"
$uri = "https://graph.microsoft.com/v1.0/sites/$sitePath/permissions"
$headers = @{
"Authorization" = "Bearer $accessToken"
"Content-Type" = "application/json"
}
$body = @{
roles = @("write")
grantedToIdentities = @(
@{
application = @{
id = "11111111-2222-3333-4444-555555555555"
displayName = "My Azure App Registration"
}
}
)
} | ConvertTo-Json -Depth 5
Invoke-RestMethod -Method POST -Uri $uri -Headers $headers -Body $body
}}}\\
\\
!!! 4. Job Example:\\
\\
Sample job.XML can be downloaded here: [CrushTaskExample19/job.XML]\\
\\
[CrushTaskExample19/grant_sharepoint_site_access_job.png]\\
\\
At line 155 added 7 lines
Find any local file on the server. Settings:\\
{{{
Don't Add Folders: true
Max Items to Find: 1
Depth: 1
}}}\\
\\
At line 163 added 14 lines
You need the following variables to obtain an access token:\\
{{{
sites_full_control_client_id = XXXX-XXX-XXX-XXX
(See at App Registration -> Overview -> Application (client) ID)
sites_full_control_client_secret_password = XXXX-XXX-XXX-XXX
(See at App Registration -> Manage -> Certificates & secrets)
tenant_id = XXXX-XXX-XXX-XXX
(See at App Registration -> Overview -> Directory (tenant) ID)
get_access_token_http_post_data = client_id={sites_full_control_client_id}&scope=https%3A%2F%2Fgraph.microsoft.com%2F.default&client_secret={sites_full_control_client_secret_password}&grant_type=client_credentials
}}}\\
At line 180 added 12 lines
{{{
URL : https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token
HTTP Method: POST
POST Data: {get_access_token_http_post_data}
Expected Response Codes: 200,204
}}}\\
\\
At line 193 added 100 lines
\\
{{{
Header: Content-Type application/x-www-form-urlencoded
}}}\\
\\
}}}\\
\\
[CrushTaskExample19/parse_access_token_from_response.png]\\
\\
{{{
access_token_response = {json_parse_start}{http_response_log}{json_parse_end}
sharepoint_site_relative_path = YOUR.sharepoint.com:/sites/YOUR_Site_Path/:
}}}
\\
[CrushTaskExample19/get_site_permission_http_1.png]\\
\\
{{{
URL: https://graph.microsoft.com/v1.0/sites/{sharepoint_site_relative_path}/permissions
HTTP Method: GET
Expected Response Codes: 200,204
}}}
\\
[CrushTaskExample19/get_site_permission_http_2.png]\\
\\
{{{
Header: Authorization Bearer {access_token}
Header: Accept application/json
}}}\\
\\
[CrushTaskExample19/new_permission_related_variables.png]\\
\\
{{{
site_slected_app_id = XXXX-XXX-XXX-XXX
(See at App Registration -> Overview -> Application (client) ID)
identity_name = CrushFTP - Grant Write Access to App Registration - {site_slected_app_id}
sharepoint_grant_permission_http_post_data = {n}
"roles": [{n}
"write"{n}
],{n}
"grantedToIdentities": [{n}
{{n}
"application": {{n}
"id": "{site_slected_app_id}",{n}
"displayName": "{identity_name}"{n}
}{n}
}{n}
]{n}
}
}}}\\
\\
[CrushTaskExample19/new_permission_http_1.png]\\
\\
{{{
URL : https://graph.microsoft.com/v1.0/sites/{sharepoint_site_relative_path}/permissions
HTTP Method: POST
POST Data: {sharepoint_grant_permission_http_post_data}
Expected Response Codes: 201,204
}}}\\
\\
[CrushTaskExample19/new_permission_http_2.png]\\
\\
{{{
Header: Authorization Bearer {access_token}
Header: Content-Type application/json
Header: Accept application/json
}}}\\
\\
Reload the site permissions, including the newly created one.\\
\\
[CrushTaskExample19/get_site_permission_http_1.png]\\
\\
[CrushTaskExample19/check_new_permission.png]\\
\\
[CrushTaskExample19/error_handler_task.png]\\
\\
Version Date Modified Size Author Changes ... Change note
114 01-May-2025 04:59 9.726 kB krivacsz to previous
113 01-May-2025 04:58 9.727 kB krivacsz to previous | to last
112 01-May-2025 04:48 9.651 kB krivacsz to previous | to last
111 01-May-2025 04:48 9.659 kB krivacsz to previous | to last
110 01-May-2025 04:47 9.659 kB krivacsz to previous | to last
109 01-May-2025 02:35 9.643 kB krivacsz to previous | to last
108 01-May-2025 01:39 9.515 kB krivacsz to previous | to last
107 01-May-2025 01:38 9.522 kB krivacsz to previous | to last
106 01-May-2025 01:01 9.518 kB krivacsz to previous | to last
105 30-Apr-2025 07:56 9.471 kB krivacsz to previous | to last
104 30-Apr-2025 07:48 9.456 kB krivacsz to previous | to last
103 30-Apr-2025 07:48 9.488 kB krivacsz to previous | to last
102 30-Apr-2025 07:46 9.422 kB krivacsz to previous | to last
101 30-Apr-2025 07:44 9.319 kB krivacsz to previous | to last
« This page (revision-114) was last changed on 01-May-2025 04:59 by krivacsz
G’day (anonymous guest)
CrushFTP11 | What's New
JSPWiki