summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.OAuth2.Client/OAuth2/UserAgentClient.cs
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2012-02-21 20:24:38 -0800
committerAndrew Arnott <andrewarnott@gmail.com>2012-02-21 20:24:38 -0800
commit64c63ffe2cddf9123788c4e6e9693bd704c411af (patch)
tree8dfc00ee2e6b3acaa1fecfd01e78d5060f99b3bc /src/DotNetOpenAuth.OAuth2.Client/OAuth2/UserAgentClient.cs
parent56e0f9d8803222246b355c139c76c9480abee5c0 (diff)
downloadDotNetOpenAuth-64c63ffe2cddf9123788c4e6e9693bd704c411af.zip
DotNetOpenAuth-64c63ffe2cddf9123788c4e6e9693bd704c411af.tar.gz
DotNetOpenAuth-64c63ffe2cddf9123788c4e6e9693bd704c411af.tar.bz2
Split up end user authorization request message types between auth code and implicit.
Diffstat (limited to 'src/DotNetOpenAuth.OAuth2.Client/OAuth2/UserAgentClient.cs')
-rw-r--r--src/DotNetOpenAuth.OAuth2.Client/OAuth2/UserAgentClient.cs23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/DotNetOpenAuth.OAuth2.Client/OAuth2/UserAgentClient.cs b/src/DotNetOpenAuth.OAuth2.Client/OAuth2/UserAgentClient.cs
index d2ede6f..5131b10 100644
--- a/src/DotNetOpenAuth.OAuth2.Client/OAuth2/UserAgentClient.cs
+++ b/src/DotNetOpenAuth.OAuth2.Client/OAuth2/UserAgentClient.cs
@@ -64,15 +64,19 @@ namespace DotNetOpenAuth.OAuth2 {
/// this client to access protected data at some resource server.
/// </summary>
/// <param name="authorization">The authorization state that is tracking this particular request. Optional.</param>
+ /// <param name="implicitResponseType">
+ /// <c>true</c> to request an access token in the fragment of the response's URL;
+ /// <c>false</c> to authenticate to the authorization server and acquire the access token (and possibly a refresh token) via a private channel.
+ /// </param>
/// <param name="state">The client state that should be returned with the authorization response.</param>
/// <returns>
/// A fully-qualified URL suitable to initiate the authorization flow.
/// </returns>
- public Uri RequestUserAuthorization(IAuthorizationState authorization, string state = null) {
+ public Uri RequestUserAuthorization(IAuthorizationState authorization, bool implicitResponseType = false, string state = null) {
Requires.NotNull(authorization, "authorization");
Requires.ValidState(!string.IsNullOrEmpty(this.ClientIdentifier));
- var request = this.PrepareRequestUserAuthorization(authorization, state);
+ var request = this.PrepareRequestUserAuthorization(authorization, implicitResponseType, state);
return this.Channel.PrepareResponse(request).GetDirectUriRequest(this.Channel);
}
@@ -130,11 +134,15 @@ namespace DotNetOpenAuth.OAuth2 {
/// this client to access protected data at some resource server.
/// </summary>
/// <param name="authorization">The authorization state that is tracking this particular request. Optional.</param>
+ /// <param name="implicitResponseType">
+ /// <c>true</c> to request an access token in the fragment of the response's URL;
+ /// <c>false</c> to authenticate to the authorization server and acquire the access token (and possibly a refresh token) via a private channel.
+ /// </param>
/// <param name="state">The client state that should be returned with the authorization response.</param>
/// <returns>
/// A message to send to the authorization server.
/// </returns>
- internal EndUserAuthorizationRequest PrepareRequestUserAuthorization(IAuthorizationState authorization, string state = null) {
+ internal EndUserAuthorizationRequest PrepareRequestUserAuthorization(IAuthorizationState authorization, bool implicitResponseType = false, string state = null) {
Requires.NotNull(authorization, "authorization");
Requires.ValidState(!string.IsNullOrEmpty(this.ClientIdentifier));
@@ -142,11 +150,10 @@ namespace DotNetOpenAuth.OAuth2 {
authorization.Callback = new Uri("http://localhost/");
}
- var request = new EndUserAuthorizationRequest(this.AuthorizationServer) {
- ClientIdentifier = this.ClientIdentifier,
- Callback = authorization.Callback,
- ClientState = state,
- };
+ var request = implicitResponseType ? new EndUserAuthorizationImplicitRequest(this.AuthorizationServer) : new EndUserAuthorizationRequest(this.AuthorizationServer);
+ request.ClientIdentifier = this.ClientIdentifier;
+ request.Callback = authorization.Callback;
+ request.ClientState = state;
request.Scope.ResetContents(authorization.Scope);
return request;