diff --git a/src/Owin.Security.Providers.Twitch/TwitchAuthenticationHandler.cs b/src/Owin.Security.Providers.Twitch/TwitchAuthenticationHandler.cs index b74caa56..69040490 100644 --- a/src/Owin.Security.Providers.Twitch/TwitchAuthenticationHandler.cs +++ b/src/Owin.Security.Providers.Twitch/TwitchAuthenticationHandler.cs @@ -60,8 +60,7 @@ protected override async Task AuthenticateCoreAsync() return new AuthenticationTicket(null, properties); } - var requestPrefix = Request.Scheme + "://" + Request.Host; - var redirectUri = requestPrefix + Request.PathBase + Options.CallbackPath; + var redirectUri = GetRequestPrefix() + Request.PathBase + Options.CallbackPath; // Build up the body for the token request var body = new List> @@ -146,9 +145,7 @@ protected override Task ApplyResponseChallengeAsync() if (challenge == null) return Task.FromResult(null); var baseUri = - Request.Scheme + - Uri.SchemeDelimiter + - Request.Host + + GetRequestPrefix() + Request.PathBase; var currentUri = @@ -237,5 +234,12 @@ private async Task InvokeReplyPathAsync() return context.IsRequestCompleted; } + + private string GetRequestPrefix() + { + return !String.IsNullOrEmpty(Options.RequestPrefix) + ? Options.RequestPrefix + : Request.Scheme + Uri.SchemeDelimiter + Request.Host; + } } } \ No newline at end of file diff --git a/src/Owin.Security.Providers.Twitch/TwitchAuthenticationOptions.cs b/src/Owin.Security.Providers.Twitch/TwitchAuthenticationOptions.cs index 881c83ab..009512a2 100644 --- a/src/Owin.Security.Providers.Twitch/TwitchAuthenticationOptions.cs +++ b/src/Owin.Security.Providers.Twitch/TwitchAuthenticationOptions.cs @@ -125,6 +125,11 @@ public string Caption /// public bool ForceVerify { get; set; } + /// + /// Gets or sets the Request prefix + /// + public string RequestPrefix { get; set; } + /// /// Initializes a new ///