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

Delta Between Two Patch Sets: Src/GoogleApis.Auth.Mvc4/OAuth2/Mvc/Filters/AuthActionFilter.cs

Issue 14341043: Issue 351: Reimplement OAuth2 (Step 4): ServiceAccount and MVC (Closed) Base URL: https://google-api-dotnet-client.googlecode.com/hg/
Left Patch Set: minor Created 10 years, 5 months ago
Right Patch Set: Gus comments Created 10 years, 5 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
LEFTRIGHT
(no file at all)
1 /*
2 Copyright 2013 Google Inc
3
4 Licensed under the Apache License, Version 2.0 (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
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 */
16
17 using System.Web;
18 using System.Web.Mvc;
19
20 using Google.Apis.Auth.OAuth2.Responses;
21
22 namespace Google.Apis.Auth.OAuth2.Mvc.Filters
23 {
24 /// <summary>
25 /// An action filter which parses the query parameters into <seealso cref="A uthorizationCodeResponseUrl"/>.
26 /// </summary>
27 public class AuthorizationCodeActionFilter : ActionFilterAttribute, IActionF ilter
28 {
29 /// <summary>
30 /// Parses the request into <seealso cref="Google.Apis.Auth.OAuth2.Filte rs.AuthorizationCodeResponseUrl"/>
31 /// </summary>
32 public override void OnActionExecuting(ActionExecutingContext actionCont ext)
33 {
34 (actionContext.ActionParameters["authorizationCode"] as Authorizatio nCodeResponseUrl)
35 .ParseRequest(actionContext.RequestContext.HttpContext.Request);
36
37 base.OnActionExecuting(actionContext);
38 }
39 }
40
41 /// <summary>Auth extensions methods.</summary>
42 public static class AuthExtensions
43 {
44 /// <summary>Parses the HTTP request query parameters into the Authoriza tion code response.</summary>
45 internal static void ParseRequest(this AuthorizationCodeResponseUrl auth orizationCode, HttpRequestBase request)
46 {
47 var queryDic = HttpUtility.ParseQueryString(request.Url.Query);
48 authorizationCode.Code = queryDic["code"];
49 authorizationCode.Error = queryDic["error"];
50 authorizationCode.ErrorDescription = queryDic["error_description"];
51 authorizationCode.ErrorUri = queryDic["error_uri"];
52 authorizationCode.State = queryDic["state"];
53 }
54 }
55 }
LEFTRIGHT

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