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

Side by Side Diff: Src/GoogleApis.Authentication.OAuth2/DotNetOpenAuth/NativeApplicationClient.cs

Issue 12772043: Issues 373 (Execute Bug), 374 (Remove Tests.Utility) and 375 (Clean warnings) (Closed) Base URL: https://google-api-dotnet-client.googlecode.com/hg/
Patch Set: Error in uploading the first time Created 10 years, 11 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:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 Copyright 2011 Google Inc 2 Copyright 2011 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 24 matching lines...) Expand all
35 35
36 /// <summary> 36 /// <summary>
37 /// Initializes a new instance of the <see cref="UserAgentClient"/> clas s. 37 /// Initializes a new instance of the <see cref="UserAgentClient"/> clas s.
38 /// </summary> 38 /// </summary>
39 /// <param name="authorizationServer">The token issuer.</param> 39 /// <param name="authorizationServer">The token issuer.</param>
40 /// <param name="clientIdentifier">The client identifier.</param> 40 /// <param name="clientIdentifier">The client identifier.</param>
41 /// <param name="clientSecret">The client secret.</param> 41 /// <param name="clientSecret">The client secret.</param>
42 public NativeApplicationClient(AuthorizationServerDescription authorizat ionServer, 42 public NativeApplicationClient(AuthorizationServerDescription authorizat ionServer,
43 string clientIdentifier, 43 string clientIdentifier,
44 string clientSecret) 44 string clientSecret)
45 : base(authorizationServer, clientIdentifier, clientSecret) {} 45 : base(authorizationServer, clientIdentifier, clientSecret) { }
46 46
47 // <summary> 47 // <summary>
48 /// Initializes a new instance of the <see cref="UserAgentClient"/> clas s. 48 /// Initializes a new instance of the <see cref="UserAgentClient"/> clas s.
49 /// </summary> 49 /// </summary>
50 /// <param name="authorizationServer">The token issuer.</param> 50 /// <param name="authorizationServer">The token issuer.</param>
51 public NativeApplicationClient(AuthorizationServerDescription authorizat ionServer) 51 public NativeApplicationClient(AuthorizationServerDescription authorizat ionServer)
52 : this(authorizationServer, null, null) {} 52 : this(authorizationServer, null, null) { }
53 53
54 /// <summary> 54 /// <summary>
55 /// Initializes a new instance of the <see cref="UserAgentClient"/> clas s. 55 /// Initializes a new instance of the <see cref="UserAgentClient"/> clas s.
56 /// </summary> 56 /// </summary>
57 /// <param name="authorizationEndpoint">The authorization endpoint.</par am> 57 /// <param name="authorizationEndpoint">The authorization endpoint.</par am>
58 public NativeApplicationClient(Uri authorizationEndpoint) 58 public NativeApplicationClient(Uri authorizationEndpoint)
59 : base(new AuthorizationServerDescription { AuthorizationEndpoint = authorizationEndpoint }) {} 59 : base(new AuthorizationServerDescription { AuthorizationEndpoint = authorizationEndpoint }) { }
60 60
61 /// <summary> 61 /// <summary>
62 /// Creates the URL which should be used by the user to request the init ial authorization. 62 /// Creates the URL which should be used by the user to request the init ial authorization.
63 /// Uses the default Out-of-band-URI as a callback. 63 /// Uses the default Out-of-band-URI as a callback.
64 /// </summary> 64 /// </summary>
65 /// <param name="scope">Set of requested scopes</param> 65 /// <param name="scope">Set of requested scopes</param>
66 /// <returns>URI pointing to the authorization server</returns> 66 /// <returns>URI pointing to the authorization server</returns>
67 public new Uri RequestUserAuthorization(IEnumerable<string> scope) 67 public new Uri RequestUserAuthorization(IEnumerable<string> scope)
68 { 68 {
69 var state = new AuthorizationState(scope); 69 var state = new AuthorizationState(scope);
70 state.Callback = new Uri(OutOfBandCallbackUrl); 70 state.Callback = new Uri(OutOfBandCallbackUrl);
71 return RequestUserAuthorization(state); 71 return RequestUserAuthorization(state);
72 } 72 }
73 73
74 /// <summary> 74 /// <summary>
75 /// Creates the URL which should be used by the user to request the init ial authorization. 75 /// Creates the URL which should be used by the user to request the init ial authorization.
76 /// Uses the default Out-of-band-URI as a callback. 76 /// Uses the default Out-of-band-URI as a callback.
77 /// </summary> 77 /// </summary>
78 /// <returns>URI pointing to the authorization server</returns> 78 /// <returns>URI pointing to the authorization server</returns>
79 public new Uri RequestUserAuthorization() 79 public Uri RequestUserAuthorization()
80 { 80 {
81 return RequestUserAuthorization((IEnumerable<string>)null); 81 return RequestUserAuthorization((IEnumerable<string>)null);
82 } 82 }
83 83
84 /// <summary> 84 /// <summary>
85 /// Uses the provided authorization code to create an authorization stat e. 85 /// Uses the provided authorization code to create an authorization stat e.
86 /// </summary> 86 /// </summary>
87 /// <param name="authCode">The authorization code for getting an access token.</param> 87 /// <param name="authCode">The authorization code for getting an access token.</param>
88 /// <param name="authorizationState">The authorization. Optional.</para m> 88 /// <param name="authorizationState">The authorization. Optional.</para m>
89 /// <returns>The granted authorization, or <c>null</c> if the authorizat ion was null or rejected.</returns> 89 /// <returns>The granted authorization, or <c>null</c> if the authorizat ion was null or rejected.</returns>
90 public IAuthorizationState ProcessUserAuthorization(string authCode, IAu thorizationState authorizationState) 90 public IAuthorizationState ProcessUserAuthorization(string authCode, IAu thorizationState authorizationState)
91 { 91 {
92 if (authorizationState == null) 92 if (authorizationState == null)
93 { 93 {
94 authorizationState = new AuthorizationState(); 94 authorizationState = new AuthorizationState();
95 authorizationState.Callback = new Uri(OutOfBandCallbackUrl); 95 authorizationState.Callback = new Uri(OutOfBandCallbackUrl);
96 } 96 }
97 97
98 // Build a generic URL containing the auth code. 98 // Build a generic URL containing the auth code.
99 // This is done here as we cannot modify the DotNetOpenAuth library and the underlying method 99 // This is done here as we cannot modify the DotNetOpenAuth library and the underlying method
100 // only allows parsing an URL as a method of retrieving the Authoriz ationState. 100 // only allows parsing an URL as a method of retrieving the Authoriz ationState.
101 string url = "http://example.com/?code=" authCode; 101 string url = "http://example.com/?code=" authCode;
102 return ProcessUserAuthorization(new Uri(url), authorizationState); 102 return ProcessUserAuthorization(new Uri(url), authorizationState);
103 } 103 }
104 104
105 /// <summary> 105 /// <summary>
106 /// Uses the provided authorization code to create an authorization stat e. 106 /// Uses the provided authorization code to create an authorization stat e.
107 /// </summary> 107 /// </summary>
108 /// <param name="authCode">The authorization code for getting an access token.</param> 108 /// <param name="authCode">The authorization code for getting an access token.</param>
109 /// <returns>The granted authorization, or <c>null</c> if the authorizat ion was null or rejected.</returns> 109 /// <returns>The granted authorization, or <c>null</c> if the authorizat ion was null or rejected.</returns>
110 public IAuthorizationState ProcessUserAuthorization(string authCode) 110 public IAuthorizationState ProcessUserAuthorization(string authCode)
111 { 111 {
112 return ProcessUserAuthorization(authCode, null); 112 return ProcessUserAuthorization(authCode, null);
113 } 113 }
114 } 114 }
115 } 115 }
OLDNEW

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