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

Delta Between Two Patch Sets: Src/GoogleApis.Auth/OAuth2/AuthorizationCodeInstalledApp.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, 2 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:
Right: Side by side diff | Download
« no previous file with change/comment | « Src/GoogleApis.Auth/GoogleApis.Auth.csproj ('k') | Src/GoogleApis.Auth/OAuth2/Flows/AuthorizationCodeFlow.cs » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 public async Task<UserCredential> AuthorizeAsync(string userId, Cancella tionToken taskCancellationToken) 60 public async Task<UserCredential> AuthorizeAsync(string userId, Cancella tionToken taskCancellationToken)
61 { 61 {
62 // Try to load a token from the data store. 62 // Try to load a token from the data store.
63 var token = await Flow.LoadTokenAsync(userId, taskCancellationToken) .ConfigureAwait(false); 63 var token = await Flow.LoadTokenAsync(userId, taskCancellationToken) .ConfigureAwait(false);
64 64
65 // If the stored token is null or it doesn't have a refresh token an d the access token is expired we need· 65 // If the stored token is null or it doesn't have a refresh token an d the access token is expired we need·
66 // to retrieve a new authorization code. 66 // to retrieve a new authorization code.
67 if (token == null || (token.RefreshToken == null && token.IsExpired( flow.Clock))) 67 if (token == null || (token.RefreshToken == null && token.IsExpired( flow.Clock)))
68 { 68 {
69 // Create a authorization code request. 69 // Create an authorization code request.
70 var redirectUri = CodeReceiver.RedirectUri; 70 var redirectUri = CodeReceiver.RedirectUri;
71 AuthorizationCodeRequestUrl codeRequest = Flow.CreateAuthorizati onCodeRequest(redirectUri); 71 AuthorizationCodeRequestUrl codeRequest = Flow.CreateAuthorizati onCodeRequest(redirectUri);
72 72
73 // Receive the code. 73 // Receive the code.
74 var response = await CodeReceiver.ReceiveCodeAsync(codeRequest, taskCancellationToken) 74 var response = await CodeReceiver.ReceiveCodeAsync(codeRequest, taskCancellationToken)
75 .ConfigureAwait(false); 75 .ConfigureAwait(false);
76 76
77 if (string.IsNullOrEmpty(response.Code)) 77 if (string.IsNullOrEmpty(response.Code))
78 { 78 {
79 var errorResponse = new TokenErrorResponse(response); 79 var errorResponse = new TokenErrorResponse(response);
80 Logger.Info("Received an error. The response is: {0}", error Response); 80 Logger.Info("Received an error. The response is: {0}", error Response);
81 throw new TokenResponseException(errorResponse); 81 throw new TokenResponseException(errorResponse);
82 } 82 }
83 83
84 Logger.Debug("Received \"{0}\" code", response.Code); 84 Logger.Debug("Received \"{0}\" code", response.Code);
85 85
86 // Get the token based on the code. 86 // Get the token based on the code.
87 token = await Flow.ExchangeCodeForTokenAsync(userId, response.Co de, CodeReceiver.RedirectUri, 87 token = await Flow.ExchangeCodeForTokenAsync(userId, response.Co de, CodeReceiver.RedirectUri,
88 taskCancellationToken).ConfigureAwait(false); 88 taskCancellationToken).ConfigureAwait(false);
89 } 89 }
90 90
91 return new UserCredential(flow, userId, token); 91 return new UserCredential(flow, userId, token);
92 } 92 }
93 93
94 #endregion 94 #endregion
95 } 95 }
96 } 96 }
LEFTRIGHT

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