Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(394)

Delta Between Two Patch Sets: Src/GoogleApis.Auth.WP81/OAuth2/AuthorizationCodeBroker.cs

Issue 176220043: Issue 471: Support WP8.1 (Closed) Base URL: https://google-api-dotnet-client.googlecode.com/hg/
Left Patch Set: comments - gus and gesse Created 9 years, 8 months ago
Right Patch Set: minor Created 9 years, 8 months 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 2014 Google Inc 2 Copyright 2014 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 19 matching lines...) Expand all
30 /// <summary> 30 /// <summary>
31 /// OAuth 2.0 verification code receiver for Windows Phone 8.1 application t hat opens a Google account form so the 31 /// OAuth 2.0 verification code receiver for Windows Phone 8.1 application t hat opens a Google account form so the
32 /// users can enter their credentials and accept the application access to t heir token. 32 /// users can enter their credentials and accept the application access to t heir token.
33 ///· 33 ///·
34 /// This broker's most important method is <see cref="ReceiveCodeAsync"/>. 34 /// This broker's most important method is <see cref="ReceiveCodeAsync"/>.
35 /// The first time it is being called, it calls <code>WebAuthenticationBroke r.AuthenticateAndContinue</code> 35 /// The first time it is being called, it calls <code>WebAuthenticationBroke r.AuthenticateAndContinue</code>
36 /// so the users can authorize the app to access their private resources. Wh ile calling this method the app is 36 /// so the users can authorize the app to access their private resources. Wh ile calling this method the app is
37 /// suspended. 37 /// suspended.
38 ///· 38 ///·
39 /// When the app is being activated again, the developer MUST store the auth result (which may contain the access 39 /// When the app is being activated again, the developer MUST store the auth result (which may contain the access
40 /// code or an error) in the storage with the <code>WebAuthResult.Name</code > key. 40 /// code or an error) in the storage with the <code>SerializableWebAuthResul t.Name</code> key.
41 /// Then when the auth framework calls again the <see cref="ReceiveCodeAsync "/> it looks in the storage to find 41 /// Then when the auth framework calls again the <see cref="ReceiveCodeAsync "/> it looks in the storage to find
42 /// the auth result, and if a code was received the framework will convert i t in turn to access and refresh tokens. 42 /// the auth result, and if a code was received the framework will convert i t in turn to access and refresh tokens.
43 /// </summary> 43 /// </summary>
44 public class AuthorizationCodeBroker : ICodeReceiver 44 public class AuthorizationCodeBroker : ICodeReceiver
45 { 45 {
46 #region ICodeReceiver Members 46 #region ICodeReceiver Members
47 47
48 public string RedirectUri 48 public string RedirectUri
49 { 49 {
50 get { return GoogleAuthConsts.LocalhostRedirectUri; } 50 get { return GoogleAuthConsts.LocalhostRedirectUri; }
(...skipping 15 matching lines...) Expand all
66 await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDi spatcherPriority.Normal, 66 await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDi spatcherPriority.Normal,
67 () => action()); 67 () => action());
68 } 68 }
69 69
70 /// <summary>Asynchronously receives the authorization code.</summary> 70 /// <summary>Asynchronously receives the authorization code.</summary>
71 /// <param name="url">The authorization code request URL.</param> 71 /// <param name="url">The authorization code request URL.</param>
72 /// <param name="tcs">Task completion source whose result will be set to the authorization code.</param> 72 /// <param name="tcs">Task completion source whose result will be set to the authorization code.</param>
73 private async Task ReceiveCodeAsync(AuthorizationCodeRequestUrl url, 73 private async Task ReceiveCodeAsync(AuthorizationCodeRequestUrl url,
74 TaskCompletionSource<AuthorizationCodeResponseUrl> tcs) 74 TaskCompletionSource<AuthorizationCodeResponseUrl> tcs)
75 { 75 {
76 var result = await PasswordVaultDataStore.Default.GetAsync<Serializa bleWebAuthResult>(SerializableWebAuthResult.Name); 76 var result = await PasswordVaultDataStore.Default.GetAsync<Serializa bleWebAuthResult>(
77 SerializableWebAuthResult.Name);
77 if (result == null) 78 if (result == null)
78 { 79 {
79 // We should run WebAuthenticationBroker.AuthenticateAndContinue from the UI thread ONLY. 80 // We should run WebAuthenticationBroker.AuthenticateAndContinue from the UI thread ONLY.
80 await InvokeFromUIThread(() => WebAuthenticationBroker.Authentic ateAndContinue(url.Build(), 81 await InvokeFromUIThread(() => WebAuthenticationBroker.Authentic ateAndContinue(url.Build(),
81 new Uri(GoogleAuthConsts.LocalhostRedirectUri), null, WebAut henticationOptions.None)); 82 new Uri(GoogleAuthConsts.LocalhostRedirectUri), null, WebAut henticationOptions.None));
82 ················ 83 ················
83 // No need to return anything, cause the application is going to be suspended now. 84 // No need to return anything, cause the application is going to be suspended now.
84 return; 85 return;
85 } 86 }
86 87
(...skipping 12 matching lines...) Expand all
99 tcs.SetException(new TokenResponseException( 100 tcs.SetException(new TokenResponseException(
100 new TokenErrorResponse 101 new TokenErrorResponse
101 { 102 {
102 Error = result.ResponseStatus.ToString(), 103 Error = result.ResponseStatus.ToString(),
103 ErrorDescription = "The WebAuthenticationBroker didn't retur n a code or an error. Details: " 104 ErrorDescription = "The WebAuthenticationBroker didn't retur n a code or an error. Details: "
104 result.ResponseErrorDetail, 105 result.ResponseErrorDetail,
105 })); 106 }));
106 } 107 }
107 } 108 }
108 } 109 }
LEFTRIGHT

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