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

Unified Diff: Src/GoogleApis.Auth/OAuth2/Responses/AuthorizationCodeResponseUrl.cs

Issue 13632059: Issue 351: Reimplement OAuth2 - Step 2 (Auth PCL - only data types) (Closed) Base URL: https://google-api-dotnet-client.googlecode.com/hg/
Patch Set: minor Created 10 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Src/GoogleApis.Auth/OAuth2/Responses/AuthorizationCodeResponseUrl.cs
===================================================================
new file mode 100644
--- /dev/null
b/Src/GoogleApis.Auth/OAuth2/Responses/AuthorizationCodeResponseUrl.cs
@@ -0,0 1,107 @@
/*
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.Collections.Generic;
namespace Google.Apis.Auth.OAuth2.Responses
{
/// <summary>
/// Authorization Code response for the redirect URL after end user grants or denies authorization as specified
/// in http://tools.ietf.org/html/rfc6749#section-4.1.2.
/// <para>
/// Check that <see cref="Code"/> is not <c>null</c> or empty to verify the end-user granted authorization.
/// </para>
/// </summary>
public class AuthorizationCodeResponseUrl
{
/// <summary>Gets or sets the authorization code generated by the authorization server.</summary>
public string Code { get; set; }
/// <summary>
/// Gets or sets the state parameter matching the state parameter in the authorization request.
/// </summary>
public string State { get; set; }
/// <summary>
/// Gets or sets the error code (e.g. "invalid_request", "unauthorized_client", "access_denied",
/// "unsupported_response_type", "invalid_scope", "server_error", "temporarily_unavailable") as specified in
/// http://tools.ietf.org/html/rfc6749#section-4.1.2.1.
/// </summary>
public string Error { get; set; }
/// <summary>
/// Gets or sets the human-readable text which provides additional information used to assist the client
/// developer in understanding the error occurred.
/// </summary>
public string ErrorDescription { get; set; }
/// <summary>
/// Gets or sets the URI identifying a human-readable web page with provides information about the error.
/// </summary>
public string ErrorUri { get; set; }
/// <summary>Constructs a new authorization code response URL from the specified dictionary.</summary>
public AuthorizationCodeResponseUrl(IDictionary<string, string> queryString)
{
InitFromDictionary(queryString);
}
#region Constructs
/// <summary>Constructs a new authorization code response URL from the specified query string.</summary>
public AuthorizationCodeResponseUrl(string query)
{
var pairs = query.Split('&');
var queryString = new Dictionary<string, string>();
foreach (var pair in pairs)
{
var keyValue = pair.Split('=');
queryString[keyValue[0]] = keyValue[1];
}
InitFromDictionary(queryString);
}
/// <summary>Initializes this instance from the input dictionary.</summary>
private void InitFromDictionary(IDictionary<string, string> queryString)
{
//TODO(peleyal): improve the following code and make it a utility
IDictionary<string, Action<string>> setters = new Dictionary<string, Action<string>>();
setters["code"] = v => Code = v;
setters["state"] = v => State = v;
setters["error"] = v => Error = v;
setters["error_description"] = v => ErrorDescription = v;
setters["error_uri"] = v => ErrorUri = v;
Action<string> setter;
foreach (var pair in queryString)
{
if (setters.TryGetValue(pair.Key, out setter))
{
setter(pair.Value);
}
}
}
/// <summary>Constructs a new empty authorization code response URL.</summary>
public AuthorizationCodeResponseUrl()
{
}
#endregion
}
}
« no previous file with comments | « Src/GoogleApis.Auth/OAuth2/Requests/TokenRequest.cs ('k') | Src/GoogleApis.Auth/OAuth2/Responses/TokenErrorResponse.cs » ('j') | no next file with comments »

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