diff --git a/src/Untappd.Net/Authentication/AuthenticationHelper.cs b/src/Untappd.Net/Authentication/AuthenticationHelper.cs new file mode 100644 index 0000000..7ce21e8 --- /dev/null +++ b/src/Untappd.Net/Authentication/AuthenticationHelper.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Untappd.Net.Client; +using Untappd.Net.Request; + +namespace Untappd.Net.Authentication +{ + public static class AuthenticationHelper + { + /// + /// Redirect the user to this string. + /// + /// + /// The URL to redirect back to your application. Should listen on code as a string param + /// + public static string RedirectUserTo(IUnAuthenticadedUntappdCredentials credentials, string redirectUrl) + { + return string.Format("{0}/?client_id={1}&response_type=code&redirect_url={2}", Constants.BaseRequestString, + credentials.ClientId, redirectUrl); + } + + /// + /// Url to get the OAuth token. + /// + /// + /// + /// Data returned by the initial request(see: RedirectUserTo) + /// + public static string TokenUrl(IUnAuthenticadedUntappdCredentials credentials, string redirectUrl, string code) + { + return string.Format("{0}/?client_id={1}&client_secret={2}&response_type=code&redirect_url={3}&code={4}", + Constants.OAuthTokenEndPoint, + credentials.ClientId, + credentials.ClientSecret, + redirectUrl, + code); + } + } +} diff --git a/src/Untappd.Net/Constants.cs b/src/Untappd.Net/Constants.cs index 058817f..1c72c24 100644 --- a/src/Untappd.Net/Constants.cs +++ b/src/Untappd.Net/Constants.cs @@ -3,5 +3,6 @@ public struct Constants { public const string BaseRequestString = "https://api.untappd.com"; + public const string OAuthTokenEndPoint = "https://untappd.com/oauth/authorize"; } } diff --git a/src/Untappd.Net/Untappd.Net.csproj b/src/Untappd.Net/Untappd.Net.csproj index bf3d012..e805d63 100644 --- a/src/Untappd.Net/Untappd.Net.csproj +++ b/src/Untappd.Net/Untappd.Net.csproj @@ -46,6 +46,7 @@ +