Skip to content

Commit f9fe61f

Browse files
committed
Documentation: app principal with client certificate
1 parent 1e5d187 commit f9fe61f

1 file changed

Lines changed: 30 additions & 4 deletions

File tree

README.md

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
### About
1+
## About
22
Microsoft 365 Library for PHP.
33
A REST/OData based client library for Microsoft 365.
44

@@ -68,7 +68,7 @@ The list of supported SharePoint versions:
6868

6969
The following auth flows supported:
7070

71-
- app principals (client credentials) auth (refer [Granting access using SharePoint App-Only](https://docs.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azureacs) for a details):
71+
#### 1. app principal with client credentials:
7272

7373
```php
7474

@@ -79,8 +79,34 @@ The following auth flows supported:
7979
$ctx = (new ClientContext("{siteUrl}"))->withCredentials($credentials);
8080
```
8181

82+
Documentation:
8283

83-
- user credentials auth:
84+
- [wiki](https://github.com/vgrem/phpSPO/wiki/How-to-connect-to-SharePoint-Online-and-and-SharePoint-2013-2016-2019-on-premises--with-app-principal)
85+
- [Granting access using SharePoint App-Only](https://docs.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azureacs)
86+
87+
#### 2. app principal with client certificate:
88+
89+
```php
90+
91+
use Office365\Runtime\Auth\ClientCredential;
92+
use Office365\SharePoint\ClientContext;
93+
94+
95+
$tenant = "{tenant}.onmicrosoft.com"; //tenant id or name
96+
$privateKetPath = "-- path to private.key file--"
97+
$privateKey = file_get_contents($privateKetPath);
98+
99+
$ctx = (new ClientContext("{siteUrl}"))->withClientCertificate(
100+
$tenant, "{clientId}", $privateKey, "{thumbprint}");
101+
```
102+
103+
Documentation:
104+
105+
- [wiki](https://github.com/vgrem/phpSPO/wiki/Granting-access-via-Azure-AD-App%E2%80%90Only-with-Certificate)
106+
- [Granting access using SharePoint App-Only](https://docs.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azureacs)
107+
108+
109+
#### 3. user credentials auth:
84110

85111
```php
86112

@@ -92,7 +118,7 @@ The following auth flows supported:
92118
```
93119

94120

95-
- NTLM auth (for SharePoint On-Premises):
121+
#### 4. NTLM auth (for SharePoint On-Premises):
96122
```php
97123
use Office365\Runtime\Auth\UserCredentials;
98124
use Office365\SharePoint\ClientContext;

0 commit comments

Comments
 (0)