Skip to content

Commit e173775

Browse files
committed
[msid] syntax highlighting: protocol docs (HTTP, JSON)
1 parent 3b74c29 commit e173775

11 files changed

+72
-74
lines changed

articles/active-directory/develop/scenario-daemon-acquire-token.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ If you don't yet have a library for your chosen language, you might want to use
172172

173173
#### First case: Access the token request by using a shared secret
174174

175-
```Text
175+
```HTTP
176176
POST /{tenant}/oauth2/v2.0/token HTTP/1.1 //Line breaks for clarity.
177177
Host: login.microsoftonline.com
178178
Content-Type: application/x-www-form-urlencoded
@@ -185,7 +185,7 @@ client_id=535fb089-9ff3-47b6-9bfb-4f1264799865
185185

186186
#### Second case: Access the token request by using a certificate
187187

188-
```Text
188+
```HTTP
189189
POST /{tenant}/oauth2/v2.0/token HTTP/1.1 // Line breaks for clarity.
190190
Host: login.microsoftonline.com
191191
Content-Type: application/x-www-form-urlencoded

articles/active-directory/develop/scenario-mobile-acquire-token.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ When you use the protocol to get tokens for mobile apps, make two requests:
265265

266266
#### Get an authorization code
267267

268-
```Text
268+
```
269269
https://login.microsoftonline.com/{tenant}/oauth2/v2.0/authorize?
270270
client_id=<CLIENT_ID>
271271
&response_type=code
@@ -277,7 +277,7 @@ client_id=<CLIENT_ID>
277277

278278
#### Get access and refresh the token
279279

280-
```Text
280+
```HTTP
281281
POST /{tenant}/oauth2/v2.0/token HTTP/1.1
282282
Host: https://login.microsoftonline.com
283283
Content-Type: application/x-www-form-urlencoded

articles/active-directory/develop/v2-admin-consent.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ ms.custom: aaddev
1717

1818
# Admin consent on the Microsoft identity platform
1919

20-
Some permissions require consent from an administrator before they can be granted within a tenant. You can also use the admin consent endpoint to grant permissions to an entire tenant.
20+
Some permissions require consent from an administrator before they can be granted within a tenant. You can also use the admin consent endpoint to grant permissions to an entire tenant.
2121

2222
## Recommended: Sign the user into your app
2323

@@ -29,15 +29,15 @@ When you sign the user into your app, you can identify the organization to which
2929

3030
When you're ready to request permissions from your organization's admin, you can redirect the user to the Microsoft identity platform *admin consent endpoint*.
3131

32-
```
32+
```HTTP
3333
// Line breaks are for legibility only.
34-
GET https://login.microsoftonline.com/{tenant}/v2.0/adminconsent?
35-
client_id=6731de76-14a6-49ae-97bc-6eba6914391e
36-
&state=12345
37-
&redirect_uri=http://localhost/myapp/permissions
38-
&scope=
39-
https://graph.microsoft.com/calendars.read
40-
https://graph.microsoft.com/mail.send
34+
GET https://login.microsoftonline.com/{tenant}/v2.0/adminconsent?
35+
client_id=6731de76-14a6-49ae-97bc-6eba6914391e
36+
&state=12345
37+
&redirect_uri=http://localhost/myapp/permissions
38+
&scope=
39+
https://graph.microsoft.com/calendars.read
40+
https://graph.microsoft.com/mail.send
4141
```
4242

4343

@@ -47,7 +47,7 @@ When you're ready to request permissions from your organization's admin, you can
4747
| `client_id` | Required | The **Application (client) ID** that the [Azure portal – App registrations](https://go.microsoft.com/fwlink/?linkid=2083908) experience assigned to your app. |
4848
| `redirect_uri` | Required |The redirect URI where you want the response to be sent for your app to handle. It must exactly match one of the redirect URIs that you registered in the app registration portal. |
4949
| `state` | Recommended | A value included in the request that will also be returned in the token response. It can be a string of any content you want. Use the state to encode information about the user's state in the app before the authentication request occurred, such as the page or view they were on. |
50-
|`scope` | Required | Defines the set of permissions being requested by the application. This can be either static (using /.default) or dynamic scopes. This can include the OIDC scopes (`openid`, `profile`, `email`). |
50+
|`scope` | Required | Defines the set of permissions being requested by the application. This can be either static (using /.default) or dynamic scopes. This can include the OIDC scopes (`openid`, `profile`, `email`). |
5151

5252

5353
At this point, Azure AD requires a tenant administrator to sign in to complete the request. The administrator is asked to approve all the permissions that you have requested in the `scope` parameter. If you've used a static (`/.default`) value, it will function like the v1.0 admin consent endpoint and request consent for all scopes found in the required permissions for the app.

articles/active-directory/develop/v2-oauth-ropc.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ The ROPC flow is a single request: it sends the client identification and user's
4646
> [![Try running this request in Postman](./media/v2-oauth2-auth-code-flow/runInPostman.png)](https://app.getpostman.com/run-collection/f77994d794bab767596d)
4747
4848

49-
```
50-
// Line breaks and spaces are for legibility only. This is a public client, so no secret is required.
49+
```HTTP
50+
// Line breaks and spaces are for legibility only. This is a public client, so no secret is required.
5151
5252
POST {tenant}/oauth2/v2.0/token
5353
Host: login.microsoftonline.com
@@ -63,13 +63,13 @@ client_id=6731de76-14a6-49ae-97bc-6eba6914391e
6363
| Parameter | Condition | Description |
6464
| --- | --- | --- |
6565
| `tenant` | Required | The directory tenant that you want to log the user into. This can be in GUID or friendly name format. This parameter can't be set to `common` or `consumers`, but may be set to `organizations`. |
66-
| `client_id` | Required | The Application (client) ID that the [Azure portal - App registrations](https://go.microsoft.com/fwlink/?linkid=2083908) page assigned to your app. |
66+
| `client_id` | Required | The Application (client) ID that the [Azure portal - App registrations](https://go.microsoft.com/fwlink/?linkid=2083908) page assigned to your app. |
6767
| `grant_type` | Required | Must be set to `password`. |
6868
| `username` | Required | The user's email address. |
6969
| `password` | Required | The user's password. |
7070
| `scope` | Recommended | A space-separated list of [scopes](v2-permissions-and-consent.md), or permissions, that the app requires. In an interactive flow, the admin or the user must consent to these scopes ahead of time. |
71-
| `client_secret`| Sometimes required | If your app is a public client, then the `client_secret` or `client_assertion` cannot be included. If the app is a confidential client, then it must be included. |
72-
| `client_assertion` | Sometimes required | A different form of `client_secret`, generated using a certificate. See [certificate credentials](active-directory-certificate-credentials.md) for more details. |
71+
| `client_secret`| Sometimes required | If your app is a public client, then the `client_secret` or `client_assertion` cannot be included. If the app is a confidential client, then it must be included. |
72+
| `client_assertion` | Sometimes required | A different form of `client_secret`, generated using a certificate. See [certificate credentials](active-directory-certificate-credentials.md) for more details. |
7373

7474
### Successful authentication response
7575

articles/active-directory/develop/v2-oauth2-auth-code-flow.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ At a high level, the entire authentication flow for a native/mobile application
3131

3232
## Request an authorization code
3333

34-
The authorization code flow begins with the client directing the user to the `/authorize` endpoint. In this request, the client requests the `openid`, `offline_access`, and `https://graph.microsoft.com/mail.read `permissions from from the user. Some permissions are admin-restricted, for example writing data to an organization's directory by using `Directory.ReadWrite.All`. If your application requests access to one of these permissions from an organizational user, the user receives an error message that says they're not authorized to consent to your app's permissions. To request access to admin-restricted scopes, you should request them directly from a company administrator. For more information, read [Admin-restricted permissions](v2-permissions-and-consent.md#admin-restricted-permissions).
34+
The authorization code flow begins with the client directing the user to the `/authorize` endpoint. In this request, the client requests the `openid`, `offline_access`, and `https://graph.microsoft.com/mail.read ` permissions from from the user. Some permissions are admin-restricted, for example writing data to an organization's directory by using `Directory.ReadWrite.All`. If your application requests access to one of these permissions from an organizational user, the user receives an error message that says they're not authorized to consent to your app's permissions. To request access to admin-restricted scopes, you should request them directly from a company administrator. For more information, read [Admin-restricted permissions](v2-permissions-and-consent.md#admin-restricted-permissions).
3535

3636
```
3737
// Line breaks for legibility only
@@ -72,7 +72,7 @@ Once the user authenticates and grants consent, the Microsoft identity platform
7272

7373
A successful response using `response_mode=query` looks like:
7474

75-
```
75+
```HTTP
7676
GET https://login.microsoftonline.com/common/oauth2/nativeclient?
7777
code=AwABAAAAvPM1KaPlrEqdFSBzjqfTGBCmLdgfSTLEMPGYuNHSUYBrq...
7878
&state=12345
@@ -87,7 +87,7 @@ code=AwABAAAAvPM1KaPlrEqdFSBzjqfTGBCmLdgfSTLEMPGYuNHSUYBrq...
8787

8888
Error responses may also be sent to the `redirect_uri` so the app can handle them appropriately:
8989

90-
```
90+
```HTTP
9191
GET https://login.microsoftonline.com/common/oauth2/nativeclient?
9292
error=access_denied
9393
&error_description=the+user+canceled+the+authentication
@@ -118,7 +118,7 @@ The following table describes the various error codes that can be returned in th
118118

119119
Now that you've acquired an authorization_code and have been granted permission by the user, you can redeem the `code` for an `access_token` to the desired resource. Do this by sending a `POST` request to the `/token` endpoint:
120120

121-
```
121+
```HTTP
122122
// Line breaks for legibility only
123123
124124
POST /{tenant}/oauth2/v2.0/token HTTP/1.1
@@ -219,7 +219,7 @@ Now that you've successfully acquired an `access_token`, you can use the token i
219219
> Execute this request in Postman! (Replace the `Authorization` header first)
220220
> [![Try running this request in Postman](./media/v2-oauth2-auth-code-flow/runInPostman.png)](https://app.getpostman.com/run-collection/f77994d794bab767596d)
221221
222-
```
222+
```HTTP
223223
GET /v1.0/me/messages
224224
Host: https://graph.microsoft.com
225225
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik5HVEZ2ZEstZnl0aEV1Q...
@@ -233,7 +233,7 @@ Refresh tokens do not have specified lifetimes. Typically, the lifetimes of refr
233233

234234
Although refresh tokens aren't revoked when used to acquire new access tokens, you are expected to discard the old refresh token. The [OAuth 2.0 spec](https://tools.ietf.org/html/rfc6749#section-6) says: "The authorization server MAY issue a new refresh token, in which case the client MUST discard the old refresh token and replace it with the new refresh token. The authorization server MAY revoke the old refresh token after issuing a new refresh token to the client."
235235

236-
```
236+
```HTTP
237237
// Line breaks for legibility only
238238
239239
POST /{tenant}/oauth2/v2.0/token HTTP/1.1
@@ -275,6 +275,7 @@ A successful token response will look like:
275275
"id_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJub25lIn0.eyJhdWQiOiIyZDRkMTFhMi1mODE0LTQ2YTctOD...",
276276
}
277277
```
278+
278279
| Parameter | Description |
279280
|---------------|-------------------------------------------------------------|
280281
| `access_token` | The requested access token. The app can use this token to authenticate to the secured resource, such as a web API. |

articles/active-directory/develop/v2-oauth2-client-creds-grant-flow.md

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ When you're ready to request permissions from the organization's admin, you can
8787
> Try executing this request in Postman! (Use your own app ID for best results - the tutorial application won't request useful permissions.)
8888
> [![Try running this request in Postman](./media/v2-oauth2-auth-code-flow/runInPostman.png)](https://app.getpostman.com/run-collection/f77994d794bab767596d)
8989
90-
```
90+
```HTTP
9191
// Line breaks are for legibility only.
9292
9393
GET https://login.microsoftonline.com/{tenant}/adminconsent?
@@ -96,9 +96,7 @@ client_id=6731de76-14a6-49ae-97bc-6eba6914391e
9696
&redirect_uri=http://localhost/myapp/permissions
9797
```
9898

99-
```
100-
// Pro tip: Try pasting the following request in a browser.
101-
```
99+
Pro tip: Try pasting the following request in a browser.
102100

103101
```
104102
https://login.microsoftonline.com/common/adminconsent?client_id=6731de76-14a6-49ae-97bc-6eba6914391e&state=12345&redirect_uri=http://localhost/myapp/permissions
@@ -117,7 +115,7 @@ At this point, Azure AD enforces that only a tenant administrator can sign into
117115

118116
If the admin approves the permissions for your application, the successful response looks like this:
119117

120-
```
118+
```HTTP
121119
GET http://localhost/myapp/permissions?tenant=a8990e1f-ff32-408a-9f8e-78d3b9139b95&state=state=12345&admin_consent=True
122120
```
123121

@@ -131,7 +129,7 @@ GET http://localhost/myapp/permissions?tenant=a8990e1f-ff32-408a-9f8e-78d3b9139b
131129

132130
If the admin does not approve the permissions for your application, the failed response looks like this:
133131

134-
```
132+
```HTTP
135133
GET http://localhost/myapp/permissions?error=permission_denied&error_description=The+admin+canceled+the+request
136134
```
137135

@@ -152,7 +150,7 @@ After you've acquired the necessary authorization for your application, proceed
152150
153151
### First case: Access token request with a shared secret
154152

155-
```
153+
```HTTP
156154
POST /{tenant}/oauth2/v2.0/token HTTP/1.1 //Line breaks for clarity
157155
Host: login.microsoftonline.com
158156
Content-Type: application/x-www-form-urlencoded
@@ -163,8 +161,8 @@ client_id=535fb089-9ff3-47b6-9bfb-4f1264799865
163161
&grant_type=client_credentials
164162
```
165163

166-
```
167-
// Replace {tenant} with your tenant!
164+
```Bash
165+
# Replace {tenant} with your tenant!
168166
curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -d 'client_id=535fb089-9ff3-47b6-9bfb-4f1264799865&scope=https%3A%2F%2Fgraph.microsoft.com%2F.default&client_secret=qWgdYAmab0YSkuL1qKv5bPX&grant_type=client_credentials' 'https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token'
169167
```
170168

@@ -178,7 +176,7 @@ curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -d 'client_id=
178176

179177
### Second case: Access token request with a certificate
180178

181-
```
179+
```HTTP
182180
POST /{tenant}/oauth2/v2.0/token HTTP/1.1 // Line breaks for clarity
183181
Host: login.microsoftonline.com
184182
Content-Type: application/x-www-form-urlencoded
@@ -205,7 +203,7 @@ Notice that the parameters are almost the same as in the case of the request by
205203

206204
A successful response looks like this:
207205

208-
```
206+
```json
209207
{
210208
"token_type": "Bearer",
211209
"expires_in": 3599,
@@ -223,7 +221,7 @@ A successful response looks like this:
223221

224222
An error response looks like this:
225223

226-
```
224+
```json
227225
{
228226
"error": "invalid_scope",
229227
"error_description": "AADSTS70011: The provided value for the input parameter 'scope' is not valid. The scope https://foo.microsoft.com/.default is not valid.\r\nTrace ID: 255d1aef-8c98-452f-ac51-23d051240864\r\nCorrelation ID: fb3d2015-bc17-4bb9-bb85-30c5cf1aaaa7\r\nTimestamp: 2016-01-09 02:02:12Z",
@@ -249,17 +247,15 @@ An error response looks like this:
249247

250248
Now that you've acquired a token, use the token to make requests to the resource. When the token expires, repeat the request to the `/token` endpoint to acquire a fresh access token.
251249

252-
```
250+
```HTTP
253251
GET /v1.0/me/messages
254252
Host: https://graph.microsoft.com
255253
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik5HVEZ2ZEstZnl0aEV1Q...
256254
```
257255

258-
```
259-
// Pro tip: Try the following command! (Replace the token with your own.)
260-
```
256+
```bash
257+
# Pro tip: Try the following command! (Replace the token with your own.)
261258

262-
```
263259
curl -X GET -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbG...." 'https://graph.microsoft.com/v1.0/me/messages'
264260
```
265261

articles/active-directory/develop/v2-oauth2-device-code.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ The client must first check with the authentication server for a device and user
3636
> Try executing this request in Postman!
3737
> [![Try running this request in Postman](./media/v2-oauth2-auth-code-flow/runInPostman.png)](https://app.getpostman.com/run-collection/f77994d794bab767596d)
3838
39-
```
39+
```HTTP
4040
// Line breaks are for legibility only.
4141
4242
POST https://login.microsoftonline.com/{tenant}/oauth2/v2.0/devicecode
@@ -77,7 +77,7 @@ If the user authenticates with a personal account (on /common or /consumers), th
7777

7878
While the user is authenticating at the `verification_uri`, the client should be polling the `/token` endpoint for the requested token using the `device_code`.
7979

80-
```
80+
```HTTP
8181
POST https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token
8282
Content-Type: application/x-www-form-urlencoded
8383

articles/active-directory/develop/v2-oauth2-implicit-grant-flow.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ Once the user authenticates and grants consent, the Microsoft identity platform
113113

114114
A successful response using `response_mode=fragment` and `response_type=id_token+token` looks like the following (with line breaks for legibility):
115115

116-
```
116+
```HTTP
117117
GET https://localhost/myapp/#
118118
&token_type=Bearer
119119
&expires_in=3599
@@ -134,7 +134,7 @@ GET https://localhost/myapp/#
134134

135135
Error responses may also be sent to the `redirect_uri` so the app can handle them appropriately:
136136

137-
```
137+
```HTTP
138138
GET https://localhost/myapp/#
139139
error=access_denied
140140
&error_description=the+user+canceled+the+authentication
@@ -180,7 +180,7 @@ Thanks to the `prompt=none` parameter, this request will either succeed or fail
180180

181181
A successful response using `response_mode=fragment` looks like:
182182

183-
```
183+
```HTTP
184184
GET https://localhost/myapp/#
185185
access_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik5HVEZ2ZEstZnl0aEV1Q...
186186
&state=12345
@@ -202,7 +202,7 @@ access_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik5HVEZ2ZEstZnl0aEV1Q..
202202

203203
Error responses may also be sent to the `redirect_uri` so the app can handle them appropriately. In the case of `prompt=none`, an expected error will be:
204204

205-
```
205+
```HTTP
206206
GET https://localhost/myapp/#
207207
error=user_authentication_required
208208
&error_description=the+request+could+not+be+completed+silently

0 commit comments

Comments
 (0)