LEFT | RIGHT |
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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 if (newToken.RefreshToken == null) | 157 if (newToken.RefreshToken == null) |
158 { | 158 { |
159 newToken.RefreshToken = Token.RefreshToken; | 159 newToken.RefreshToken = Token.RefreshToken; |
160 } | 160 } |
161 | 161 |
162 Token = newToken; | 162 Token = newToken; |
163 return true; | 163 return true; |
164 } | 164 } |
165 | 165 |
166 /// <summary> | 166 /// <summary> |
167 /// Revokes the token by calling to | 167 /// Asynchronously revokes the token by calling |
168 /// <see cref="Google.Apis.Auth.OAuth2.Flows.IAuthorizationCodeFlow.Revo
keTokenAsync"/>. | 168 /// <see cref="Google.Apis.Auth.OAuth2.Flows.IAuthorizationCodeFlow.Revo
keTokenAsync"/>. |
169 /// Then it updates the <see cref="TokenResponse"/> to <code>null</code>
. | |
170 /// </summary> | 169 /// </summary> |
171 /// <param name="taskCancellationToken">Cancellation token to cancel an
operation.</param> | 170 /// <param name="taskCancellationToken">Cancellation token to cancel an
operation.</param> |
172 /// <returns><c>true</c> if the token was revoked successfully.</returns
> | 171 /// <returns><c>true</c> if the token was revoked successfully.</returns
> |
173 public async Task<bool> RevokeTokenAsync(CancellationToken taskCancellat
ionToken) | 172 public async Task<bool> RevokeTokenAsync(CancellationToken taskCancellat
ionToken) |
174 { | 173 { |
175 if (Token == null) | 174 if (Token == null) |
176 { | 175 { |
177 Logger.Warning("Token is already null, no need to revoke it."); | 176 Logger.Warning("Token is already null, no need to revoke it."); |
178 return false; | 177 return false; |
179 } | 178 } |
180 | 179 |
181 await flow.RevokeTokenAsync(userId, Token.AccessToken, taskCancellat
ionToken).ConfigureAwait(false); | 180 await flow.RevokeTokenAsync(userId, Token.AccessToken, taskCancellat
ionToken).ConfigureAwait(false); |
182 Logger.Info("Access token was revoked successfully"); | 181 Logger.Info("Access token was revoked successfully"); |
183 // We don't set the token to null, cause we want that the next reque
st (without reauthorizing will fail), | 182 // We don't set the token to null, cause we want that the next reque
st (without reauthorizing) will fail). |
184 // but we do clean the datastore. | |
185 return true; | 183 return true; |
186 } | 184 } |
187 } | 185 } |
188 } | 186 } |
LEFT | RIGHT |