Skip to content

Commit

Permalink
Fix bug with BotWebAgent requesting a post through a full url. Attach…
Browse files Browse the repository at this point in the history
…ing bearer token to a non oauth request apparently causes 403s
  • Loading branch information
CrustyJew committed Dec 21, 2016
1 parent 6daef8f commit 8f0c816
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions RedditSharp/WebAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public virtual HttpWebRequest CreateRequest(string url, string method)
else
request = (HttpWebRequest)WebRequest.Create(url);
request.CookieContainer = Cookies;
if (IsOAuth())// use OAuth
if (IsOAuth() && request.Host.ToLower() == "oauth.reddit.com")// use OAuth
{
request.Headers.Set("Authorization", "bearer " + AccessToken);//Must be included in OAuth calls
}
Expand All @@ -249,7 +249,7 @@ protected virtual HttpWebRequest CreateRequest(Uri uri, string method)
var cookieHeader = Cookies.GetCookieHeader(new Uri("http://reddit.com"));
request.Headers.Set("Cookie", cookieHeader);
}
if (IsOAuth())// use OAuth
if (IsOAuth() && uri.Host.ToLower() == "oauth.reddit.com")// use OAuth
{
request.Headers.Set("Authorization", "bearer " + AccessToken);//Must be included in OAuth calls
}
Expand Down

0 comments on commit 8f0c816

Please sign in to comment.