Index: Src/GoogleApis.Auth/OAuth2/IAuthorizationCodeFlow.cs =================================================================== new file mode 100644 --- /dev/null +++ b/Src/GoogleApis.Auth/OAuth2/IAuthorizationCodeFlow.cs @@ -0,0 +1,70 @@ +/* +Copyright 2013 Google Inc + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +using System; +using System.Threading; +using System.Threading.Tasks; + +using Google.Apis.Auth.OAuth2.Responses; +using Google.Apis.Auth.OAuth2.Requests; +using Google.Apis.Util; +using Google.Apis.Util.Store; + +namespace Google.Apis.Auth.OAuth2 +{ + /// OAuth 2.0 authorization code flow that manages and persists end-user credentials. + public interface IAuthorizationCodeFlow : IDisposable + { + /// Gets the method for presenting the access token to the resource server. + IAccessMethod AccessMethod { get; } + + /// Gets the clock. + IClock Clock { get; } + + /// Gets the data store used to store the credentials. + IDataStore DataStore { get; } + + /// Loads the user's token using the flow's . + /// User identifier + /// Cancellation token to cancel operation + /// Token response + Task LoadToken(string userId, CancellationToken taskCancellationToken); + + /// Deletes the user's token using the flow's . + /// User identifier + /// Cancellation token to cancel operation + Task DeleteToken(string userId, CancellationToken taskCancellationToken); + + /// Creates an authorization code request with the specified redirect URI. + AuthorizationCodeRequestUrl CreateAuthorizationCodeRequest(string redirectUri); + + /// Exchanges code with a token. + /// User identifier + /// Authorization code received from the authorization server + /// Redirect URI which is used in the token request + /// Cancellation token to cancel operation + /// Token response which contains the access token + Task ExchangeCodeForToken(string userId, string code, string redirectUri, + CancellationToken taskCancellationToken); + + /// Refreshes an access token using a refresh token. + /// User identifier + /// Refresh token which is used to get a new access token + /// Cancellation token to cancel operation + /// Token response which contains the access token and the input refresh token + Task RefreshToken(string userId, string refreshToken, CancellationToken taskCancellationToken); + } +}