diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2011-06-26 19:55:28 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2011-06-26 19:55:28 -0700 |
commit | 1498e4d316838850cbfc40628c70b20b108e340b (patch) | |
tree | 1ef7695d44e2ec2e491d6d9370b41dcd03a9dc4b /src | |
parent | 37f71488eba9e010ae7c3a8b4839caeb905dcf58 (diff) | |
parent | 9428480e11968a3df460cf7192f43b9d7cfc6ce4 (diff) | |
download | DotNetOpenAuth-1498e4d316838850cbfc40628c70b20b108e340b.zip DotNetOpenAuth-1498e4d316838850cbfc40628c70b20b108e340b.tar.gz DotNetOpenAuth-1498e4d316838850cbfc40628c70b20b108e340b.tar.bz2 |
Merge branch 'v3.4'
Conflicts:
samples/OAuthClient/OAuthClient.csproj
Diffstat (limited to 'src')
-rw-r--r-- | src/DotNetOpenAuth/Messaging/MultipartPostPart.cs | 4 | ||||
-rw-r--r-- | src/DotNetOpenAuth/OAuth/ConsumerBase.cs | 27 |
2 files changed, 29 insertions, 2 deletions
diff --git a/src/DotNetOpenAuth/Messaging/MultipartPostPart.cs b/src/DotNetOpenAuth/Messaging/MultipartPostPart.cs index 029cd48..eff40dd 100644 --- a/src/DotNetOpenAuth/Messaging/MultipartPostPart.cs +++ b/src/DotNetOpenAuth/Messaging/MultipartPostPart.cs @@ -40,10 +40,10 @@ namespace DotNetOpenAuth.Messaging { } /// <summary> - /// Gets the content disposition. + /// Gets or sets the content disposition. /// </summary> /// <value>The content disposition.</value> - public string ContentDisposition { get; private set; } + public string ContentDisposition { get; set; } /// <summary> /// Gets the key=value attributes that appear on the same line as the Content-Disposition. diff --git a/src/DotNetOpenAuth/OAuth/ConsumerBase.cs b/src/DotNetOpenAuth/OAuth/ConsumerBase.cs index 2af6988..d9fa889 100644 --- a/src/DotNetOpenAuth/OAuth/ConsumerBase.cs +++ b/src/DotNetOpenAuth/OAuth/ConsumerBase.cs @@ -76,6 +76,33 @@ namespace DotNetOpenAuth.OAuth { internal OAuthChannel OAuthChannel { get; set; } /// <summary> + /// Obtains an access token for a new account at the Service Provider via 2-legged OAuth. + /// </summary> + /// <param name="requestParameters">Any applicable parameters to include in the query string of the token request.</param> + /// <returns>The access token.</returns> + /// <remarks> + /// The token secret is stored in the <see cref="TokenManager"/>. + /// </remarks> + public string RequestNewClientAccount(IDictionary<string, string> requestParameters = null) { + // Obtain an unauthorized request token. Assume the OAuth version given in the service description. + var token = new UnauthorizedTokenRequest(this.ServiceProvider.RequestTokenEndpoint, this.ServiceProvider.Version) { + ConsumerKey = this.ConsumerKey, + }; + var tokenAccessor = this.Channel.MessageDescriptions.GetAccessor(token); + tokenAccessor.AddExtraParameters(requestParameters); + var requestTokenResponse = this.Channel.Request<UnauthorizedTokenResponse>(token); + this.TokenManager.StoreNewRequestToken(token, requestTokenResponse); + + var requestAccess = new AuthorizedTokenRequest(this.ServiceProvider.AccessTokenEndpoint, this.ServiceProvider.Version) { + RequestToken = requestTokenResponse.RequestToken, + ConsumerKey = this.ConsumerKey, + }; + var grantAccess = this.Channel.Request<AuthorizedTokenResponse>(requestAccess); + this.TokenManager.ExpireRequestTokenAndStoreNewAccessToken(this.ConsumerKey, requestTokenResponse.RequestToken, grantAccess.AccessToken, grantAccess.TokenSecret); + return grantAccess.AccessToken; + } + + /// <summary> /// Creates a web request prepared with OAuth authorization /// that may be further tailored by adding parameters by the caller. /// </summary> |