[go: nahoru, domu]

Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(412)
Delta Between Two Patch Sets: Src/GoogleApis.Auth.WinRT/OAuth2/AuthorizationCodeWinRTInstalledApp.cs
Issue 94340043: Issue 463: Provide a signout\logout method (Closed) Base URL: https://google-api-dotnet-client.googlecode.com/hg/
Left Patch Set: Created 10 years, 2 months ago
Right Patch Set: Gus' comments Created 10 years, 1 month ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
1 /* 1 /*
2 Copyright 2013 Google Inc 2 Copyright 2013 Google Inc
3 3
4 Licensed under the Apache License, Version 2.0 (the "License"); 4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License. 5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at 6 You may obtain a copy of the License at
7 7
8 http://www.apache.org/licenses/LICENSE-2.0 8 http://www.apache.org/licenses/LICENSE-2.0
9 9
10 Unless required by applicable law or agreed to in writing, software 10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS, 11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and 13 See the License for the specific language governing permissions and
14 limitations under the License. 14 limitations under the License.
15 */ 15 */
16 16
17 using System; 17 using System;
18 using System.Threading; 18 using System.Threading;
19 using System.Threading.Tasks; 19 using System.Threading.Tasks;
20 20
21 using Google.Apis.Auth.OAuth2.Flows; 21 using Google.Apis.Auth.OAuth2.Flows;
22 22
23 namespace Google.Apis.Auth.OAuth2 23 namespace Google.Apis.Auth.OAuth2
24 { 24 {
25 /// <summary> 25 /// <summary>
26 /// OAuth 2.0 authorization code flow for a Windows 8 installed applications that persists end-user credentials. 26 /// OAuth 2.0 authorization code flow for a Windows 8 installed applications that persists end-user credentials.
27 /// <remarks> 27 /// <remarks>
28 /// This installed app class uses an internal <see cref="AuthorizationCodeIn stalledApp"/> with a 28 /// This installed app class uses an internal <seealso cref="AuthorizationCo deInstalledApp"/> with a
29 /// <see cref="Google.Apis.Auth.OAuth2.AuthorizationCodeBroker"/> for retrie ving the authorization code.· 29 /// <seealso cref="Google.Apis.Auth.OAuth2.AuthorizationCodeBroker"/> for re trieving the authorization code.·
30 /// </remarks> 30 /// </remarks>
31 /// </summary> 31 /// </summary>
32 public sealed class AuthorizationCodeWinRTInstalledApp : IAuthorizationCodeI nstalledApp 32 public sealed class AuthorizationCodeWinRTInstalledApp : IAuthorizationCodeI nstalledApp
33 { 33 {
34 private IAuthorizationCodeInstalledApp innerInstallApp; 34 private readonly IAuthorizationCodeInstalledApp innerInstallApp;
35 35
36 private readonly GoogleAuthorizationCodeFlow.Initializer authorizationCo deFlowInitializer; 36 /// <summary>
37 /// Constructs a new authorization code for Windows Store application ta rgeting an installed application flow.
38 /// </summary>
39 /// <param name="authorizationCodeFlowInitializer">An authorization code flow initializer.</param>
40 public AuthorizationCodeWinRTInstalledApp(AuthorizationCodeFlow.Initiali zer authorizationCodeFlowInitializer)
41 {
42 innerInstallApp = new AuthorizationCodeInstalledApp(
43 new AuthorizationCodeFlow(authorizationCodeFlowInitializer), new AuthorizationCodeBroker());
44 }
37 45
38 /// <summary>Constructs a new authorization code installed application f or Windows Store.</summary> 46 /// <summary>
39 /// <param name="authorizationCodeFlowInitializer">A authorization code flow initializer</param> 47 /// Constructs a new authorization code for Windows Store application ta rgeting an installed application flow.
40 public AuthorizationCodeWinRTInstalledApp( 48 /// </summary>
41 GoogleAuthorizationCodeFlow.Initializer authorizationCodeFlowInitial izer) 49 /// <param name="flow">An authorization code flow.</param>
50 public AuthorizationCodeWinRTInstalledApp(IAuthorizationCodeFlow flow)
42 { 51 {
43 this.authorizationCodeFlowInitializer = authorizationCodeFlowInitial izer; 52 innerInstallApp = new AuthorizationCodeInstalledApp(flow, new Author izationCodeBroker());
44 } 53 }
45 54
46 #region IAuthorizationCodeInstalledApp Members 55 #region IAuthorizationCodeInstalledApp Members
47 56
48 public IAuthorizationCodeFlow Flows 57 public IAuthorizationCodeFlow Flow
49 { 58 {
50 get { return innerInstallApp.Flow; } 59 get { return innerInstallApp.Flow; }
51 } 60 }
52 61
53 public ICodeReceiver CodeReceiver 62 public ICodeReceiver CodeReceiver
54 { 63 {
55 get { return innerInstallApp.CodeReceiver; } 64 get { return innerInstallApp.CodeReceiver; }
56 } 65 }
57 66
58 public async Task<UserCredential> AuthorizeAsync(string userId, Cancella tionToken taskCancellationToken) 67 public async Task<UserCredential> AuthorizeAsync(string userId, Cancella tionToken taskCancellationToken)
59 { 68 {
60 if (innerInstallApp == null)
61 {
62 // TODO(peleyal): We should create here AuthorizationCodeFlow, a nd in an inherited class (e.g.
63 // GoogleAuthorizationCodeWinRTInstalledApp) create GoogleAuthor izationCodeFlow
64 innerInstallApp = new AuthorizationCodeInstalledApp(
65 new GoogleAuthorizationCodeFlow(authorizationCodeFlowInitial izer), new AuthorizationCodeBroker());
66 }
67
68 return await innerInstallApp.AuthorizeAsync(userId, taskCancellation Token).ConfigureAwait(false); 69 return await innerInstallApp.AuthorizeAsync(userId, taskCancellation Token).ConfigureAwait(false);
69 } 70 }
70 71
71 #endregion 72 #endregion
72 } 73 }
73 } 74 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b