diff options
Diffstat (limited to 'samples/OAuthConsumer/SampleWcf2.aspx.cs')
-rw-r--r-- | samples/OAuthConsumer/SampleWcf2.aspx.cs | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/samples/OAuthConsumer/SampleWcf2.aspx.cs b/samples/OAuthConsumer/SampleWcf2.aspx.cs index b8eda9e..7fae00b 100644 --- a/samples/OAuthConsumer/SampleWcf2.aspx.cs +++ b/samples/OAuthConsumer/SampleWcf2.aspx.cs @@ -15,7 +15,7 @@ using OAuthConsumer.SampleServiceProvider; public partial class SampleWcf2 : System.Web.UI.Page { - private static InMemoryClientTokenManager TokenManager = new InMemoryClientTokenManager(); + private static InMemoryClientTokenManager tokenManager = new InMemoryClientTokenManager(); private static IAuthorizationState Authorization { get { return (AuthorizationState)HttpContext.Current.Session["Authorization"]; } @@ -44,7 +44,7 @@ var client = CreateClient(); string clientState; - var response = client.PrepareRequestUserAuthorization(TokenManager.NewAuthorization(scope, out clientState)); + var response = client.PrepareRequestUserAuthorization(tokenManager.NewAuthorization(scope, out clientState)); response.ClientState = clientState; client.Channel.Send(response); } @@ -75,9 +75,24 @@ } } + private static WebServerClient CreateClient() { + var authServerDescription = new AuthorizationServerDescription { + TokenEndpoint = new Uri("http://localhost:65169/OAuth2.ashx/token"), + AuthorizationEndpoint = new Uri("http://localhost:65169/OAuth2.ashx/auth"), + }; + + var client = new WebServerClient(authServerDescription) { + ClientIdentifier = "sampleconsumer", + ClientSecret = "samplesecret", + TokenManager = tokenManager, + }; + + return client; + } + private T CallService<T>(Func<DataApiClient, T> predicate) { DataApiClient client = new DataApiClient(); - //var serviceEndpoint = new MessageReceivingEndpoint(client.Endpoint.Address.Uri, HttpDeliveryMethods.AuthorizationHeaderRequest | HttpDeliveryMethods.PostRequest); + ////var serviceEndpoint = new MessageReceivingEndpoint(client.Endpoint.Address.Uri, HttpDeliveryMethods.AuthorizationHeaderRequest | HttpDeliveryMethods.PostRequest); if (Authorization == null) { throw new InvalidOperationException("No access token!"); } @@ -93,18 +108,5 @@ return predicate(client); } } - - private static WebServerClient CreateClient() { - var authServerDescription = new AuthorizationServerDescription { - TokenEndpoint = new Uri("http://localhost:65169/OAuth2.ashx/token"), - AuthorizationEndpoint = new Uri("http://localhost:65169/OAuth2.ashx/auth"), - }; - var client = new WebServerClient(authServerDescription) { - ClientIdentifier = "sampleconsumer", - ClientSecret = "samplesecret", - TokenManager = TokenManager, - }; - return client; - } } }
\ No newline at end of file |