Skip to content

Commit 72a2b8d

Browse files
committed
Add tabbed UI for code blocks
1 parent 42c1e8f commit 72a2b8d

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

hub/apps/develop/security/oauth2.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ The OAuth2Manager is different than the existing WinRT [WebAuthenticationBroker]
2727

2828
The following example demonstrates how to perform an authorization code request using the OAuth2Manager API in Windows App SDK:
2929

30+
# [C++](#tab/cpp)
31+
3032
```cpp
3133
// Get the WindowId for the application window
3234
Microsoft::UI::WindowId parentWindowId = this->AppWindow().Id();
@@ -52,6 +54,8 @@ else
5254
}
5355
```
5456
57+
# [C#](#tab/csharp)
58+
5559
```csharp
5660
// Get the WindowId for the application window
5761
Microsoft.UI.WindowId parentWindowId = this.AppWindow.Id;
@@ -78,10 +82,14 @@ else
7882
}
7983
```
8084

85+
---
86+
8187
### Exchange authorization code for access token
8288

8389
The following example demonstrates how to exchange an authorization code for an access token using the OAuth2Manager API in Windows App SDK:
8490

91+
# [C++](#tab/cpp)
92+
8593
```cpp
8694
AuthResponse authResponse = authRequestResult.Response();
8795
TokenRequestParams tokenRequestParams = TokenRequestParams::CreateForAuthorizationCodeRequest(authResponse);
@@ -124,6 +132,8 @@ else
124132
}
125133
```
126134
135+
# [C#](#tab/csharp)
136+
127137
```csharp
128138
AuthResponse authResponse = authRequestResult.Response;
129139
TokenRequestParams tokenRequestParams = TokenRequestParams.CreateForAuthorizationCodeRequest(authResponse);
@@ -167,10 +177,14 @@ else
167177
}
168178
```
169179

180+
---
181+
170182
### Refresh an access token
171183

172184
The following example shows how to refresh an access token using the OAuth2Manager API in Windows App SDK:
173185

186+
# [C++](#tab/cpp)
187+
174188
```cpp
175189
TokenRequestParams tokenRequestParams = TokenRequestParams::CreateForRefreshToken(refreshToken);
176190
ClientAuthentication clientAuth = ClientAuthentication::CreateForBasicAuthorization(L"my_client_id",
@@ -207,6 +221,8 @@ else
207221
}
208222
```
209223
224+
# [C#](#tab/csharp)
225+
210226
```csharp
211227
TokenRequestParams tokenRequestParams = TokenRequestParams.CreateForRefreshToken(refreshToken);
212228
ClientAuthentication clientAuth = ClientAuthentication.CreateForBasicAuthorization("my_client_id",
@@ -243,10 +259,14 @@ else
243259
}
244260
```
245261

262+
---
263+
246264
### Complete an authorization request
247265

248266
Finally, to complete an authorization request from a protocol activation, use the following code:
249267

268+
# [C++](#tab/cpp)
269+
250270
```cpp
251271
void App::OnActivated(const IActivatedEventArgs& args)
252272
{
@@ -263,6 +283,8 @@ void App::OnActivated(const IActivatedEventArgs& args)
263283
}
264284
```
265285
286+
# [C#](#tab/csharp)
287+
266288
```csharp
267289
protected override void OnActivated(IActivatedEventArgs args)
268290
{
@@ -279,6 +301,8 @@ protected override void OnActivated(IActivatedEventArgs args)
279301
}
280302
```
281303

304+
---
305+
282306
## Related content
283307

284308
[WebAuthenticationBroker](/uwp/api/windows.security.authentication.web.webauthenticationbroker)

0 commit comments

Comments
 (0)