OLD | NEW |
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 |
(...skipping 13 matching lines...) Expand all Loading... |
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 <seealso cref="AuthorizationCo
deInstalledApp"/> with a | 28 /// This installed app class uses an internal <seealso cref="AuthorizationCo
deInstalledApp"/> with a |
29 /// <seealso cref="Google.Apis.Auth.OAuth2.AuthorizationCodeBroker"/> for re
trieving 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 AuthorizationCodeFlow.Initializer authorizationCodeFlow
Initializer; | 36 /// <summary> |
37 | 37 /// Constructs a new authorization code for Windows Store application ta
rgeting an installed application flow. |
38 /// <summary>Constructs a new authorization code installed application f
or Windows Store.</summary> | 38 /// </summary> |
39 /// <param name="authorizationCodeFlowInitializer">A authorization code
flow initializer</param> | 39 /// <param name="authorizationCodeFlowInitializer">An authorization code
flow initializer.</param> |
40 public AuthorizationCodeWinRTInstalledApp(AuthorizationCodeFlow.Initiali
zer authorizationCodeFlowInitializer) | 40 public AuthorizationCodeWinRTInstalledApp(AuthorizationCodeFlow.Initiali
zer authorizationCodeFlowInitializer) |
41 { | 41 { |
42 this.authorizationCodeFlowInitializer = authorizationCodeFlowInitial
izer; | 42 innerInstallApp = new AuthorizationCodeInstalledApp( |
| 43 new AuthorizationCodeFlow(authorizationCodeFlowInitializer), new
AuthorizationCodeBroker()); |
| 44 } |
| 45 |
| 46 /// <summary> |
| 47 /// Constructs a new authorization code for Windows Store application ta
rgeting an installed application flow. |
| 48 /// </summary> |
| 49 /// <param name="flow">An authorization code flow.</param> |
| 50 public AuthorizationCodeWinRTInstalledApp(IAuthorizationCodeFlow flow) |
| 51 { |
| 52 innerInstallApp = new AuthorizationCodeInstalledApp(flow, new Author
izationCodeBroker()); |
43 } | 53 } |
44 | 54 |
45 #region IAuthorizationCodeInstalledApp Members | 55 #region IAuthorizationCodeInstalledApp Members |
46 | 56 |
47 public IAuthorizationCodeFlow Flow | 57 public IAuthorizationCodeFlow Flow |
48 { | 58 { |
49 get { return innerInstallApp.Flow; } | 59 get { return innerInstallApp.Flow; } |
50 } | 60 } |
51 | 61 |
52 public ICodeReceiver CodeReceiver | 62 public ICodeReceiver CodeReceiver |
53 { | 63 { |
54 get { return innerInstallApp.CodeReceiver; } | 64 get { return innerInstallApp.CodeReceiver; } |
55 } | 65 } |
56 | 66 |
57 public async Task<UserCredential> AuthorizeAsync(string userId, Cancella
tionToken taskCancellationToken) | 67 public async Task<UserCredential> AuthorizeAsync(string userId, Cancella
tionToken taskCancellationToken) |
58 { | 68 { |
59 if (innerInstallApp == null) | |
60 { | |
61 innerInstallApp = new AuthorizationCodeInstalledApp( | |
62 new AuthorizationCodeFlow(authorizationCodeFlowInitializer),
new AuthorizationCodeBroker()); | |
63 } | |
64 | |
65 return await innerInstallApp.AuthorizeAsync(userId, taskCancellation
Token).ConfigureAwait(false); | 69 return await innerInstallApp.AuthorizeAsync(userId, taskCancellation
Token).ConfigureAwait(false); |
66 } | 70 } |
67 | 71 |
68 #endregion | 72 #endregion |
69 } | 73 } |
70 } | 74 } |
OLD | NEW |