From 160574010783cfc6900ab71b3508aff5d0370e0d Mon Sep 17 00:00:00 2001 From: Tobias Klika Date: Fri, 18 Jul 2014 11:54:47 +0200 Subject: [PATCH] fixes #27 Implement WebAuthenticationBroker-view toggle see: http://getpocket.com/developer/docs/getstarted/windows8 --- CHANGELOG.md | 4 ++ PocketSharp/Components/Account.cs | 52 +++++++++++++------------- PocketSharp/PocketClient.cs | 10 ++++- PocketSharp/Properties/AssemblyInfo.cs | 4 +- 4 files changed, 41 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ffa45b..2f1335e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### 4.1.4 (2014-07-18) + +- Implement WebAuthenticationBroker-view toggle + ### 4.1.3 (2014-06-25) - Only dispose response if available diff --git a/PocketSharp/Components/Account.cs b/PocketSharp/Components/Account.cs index ddfda20..d194aac 100644 --- a/PocketSharp/Components/Account.cs +++ b/PocketSharp/Components/Account.cs @@ -60,7 +60,32 @@ namespace PocketSharp RequestCode = requestCode; } - return new Uri(String.Format(authentificationUri, RequestCode, CallbackUri, isMobileClient ? "1" : "0", "login")); + return new Uri(String.Format(authentificationUri, RequestCode, CallbackUri, isMobileClient ? "1" : "0", "login", useInsideWebAuthenticationBroker ? "1" : "0")); + } + + + /// + /// Generate registration URI from requestCode + /// Follow the steps as with GenerateAuthenticationUri, but for unregistered users + /// + /// The requestCode. If no requestCode is supplied, the property from the PocketClient intialization is used. + /// A valid URI to redirect the user to. + /// Call GetRequestCode() first to receive a request_code + public Uri GenerateRegistrationUri(string requestCode = null) + { + // check if request code is available + if (RequestCode == null && requestCode == null) + { + throw new NullReferenceException("Call GetRequestCode() first to receive a request_code"); + } + + // override property with given param if available + if (requestCode != null) + { + RequestCode = requestCode; + } + + return new Uri(String.Format(authentificationUri, RequestCode, CallbackUri, isMobileClient ? "1" : "0", "signup", useInsideWebAuthenticationBroker ? "1" : "0")); } @@ -99,30 +124,5 @@ namespace PocketSharp return response; } - - - /// - /// Generate registration URI from requestCode - /// Follow the steps as with GenerateAuthenticationUri, but for unregistered users - /// - /// The requestCode. If no requestCode is supplied, the property from the PocketClient intialization is used. - /// A valid URI to redirect the user to. - /// Call GetRequestCode() first to receive a request_code - public Uri GenerateRegistrationUri(string requestCode = null) - { - // check if request code is available - if (RequestCode == null && requestCode == null) - { - throw new NullReferenceException("Call GetRequestCode() first to receive a request_code"); - } - - // override property with given param if available - if (requestCode != null) - { - RequestCode = requestCode; - } - - return new Uri(String.Format(authentificationUri, RequestCode, CallbackUri, isMobileClient ? "1" : "0", "signup")); - } } } diff --git a/PocketSharp/PocketClient.cs b/PocketSharp/PocketClient.cs index 6485c18..8cf7f5c 100644 --- a/PocketSharp/PocketClient.cs +++ b/PocketSharp/PocketClient.cs @@ -45,13 +45,18 @@ namespace PocketSharp /// /// The authentification URL /// - protected string authentificationUri = "https://getpocket.com/auth/authorize?request_token={0}&redirect_uri={1}&mobile={2}&force={3}"; + protected string authentificationUri = "https://getpocket.com/auth/authorize?request_token={0}&redirect_uri={1}&mobile={2}&force={3}&webauthenticationbroker={4}"; /// /// Indicates, whether this client is used for mobile or desktop /// protected bool isMobileClient = true; + /// + /// Indicates, whether this client is used inside a broker (on Windows 8) + /// + protected bool useInsideWebAuthenticationBroker = true; + /// /// Indicates, whether the last HTTP response is cached /// @@ -108,6 +113,7 @@ namespace PocketSharp /// The HttpMessage handler. /// Request timeout (in seconds). /// Indicates, whether this client is used for mobile or desktop + /// Indicates, whether this client is used inside a broker (on Windows 8), see: http://getpocket.com/developer/docs/getstarted/windows8 /// Enables the wrapper for the private Text Parser API /// Caches the last HTTP response in public properties public PocketClient( @@ -117,6 +123,7 @@ namespace PocketSharp HttpMessageHandler handler = null, int? timeout = null, bool isMobileClient = true, + bool useInsideWebAuthenticationBroker = false, Uri parserUri = null, bool cacheHTTPResponseData = true) { @@ -124,6 +131,7 @@ namespace PocketSharp ConsumerKey = consumerKey; this.isMobileClient = isMobileClient; + this.useInsideWebAuthenticationBroker = useInsideWebAuthenticationBroker; this.cacheHTTPResponseData = cacheHTTPResponseData; // assign access code if submitted diff --git a/PocketSharp/Properties/AssemblyInfo.cs b/PocketSharp/Properties/AssemblyInfo.cs index 47c8853..4acfeb0 100644 --- a/PocketSharp/Properties/AssemblyInfo.cs +++ b/PocketSharp/Properties/AssemblyInfo.cs @@ -22,5 +22,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("4.1.3")] -[assembly: AssemblyFileVersion("4.1.3")] \ No newline at end of file +[assembly: AssemblyVersion("4.1.4")] +[assembly: AssemblyFileVersion("4.1.4")] \ No newline at end of file