You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if (accessGrant != null)
{
//Until explict GitHub endpoints have API bindings, the following
//method can be employed to consume GitHub endpoints
var gitHubClient = _gitHubProvider.GetApi(accessGrant.AccessToken);
var result = gitHubClient.RestOperations.GetForObject<JsonValue>("https://api.github.com/user/repos");
ViewBag.AccessToken = accessGrant.AccessToken;
ViewBag.ResultText = result.ToString();
return View();
}
This is throwing the following Exception:
"System.Net.WebException: The server committed a protocol violation. Section=ResponseStatusLine"
This is happening because GitHub requires a User-Agent header along with the request. To solve this problem is very easy.
I upgraded to the latest Spring.Social.Core package, which is 4.3.0 as of this writing.
I then modified the above code to an exchange() rather than a GetForObject()
if(accessGrant != null)
{
HttpHeaders headers = new HttpHeaders();
headers.Set("User-Agent", "{Some agent name}");
HttpEntity entity = new HttpEntity(headers);
var gitHubClient = _gitHubProvider.GetApi(accessGrant.AccessToken);
var result = gitHubClient.RestOperations.Exchange<JsonValue>("https://api.github.com/user", HttpMethod.GET, entity);
ViewBag.AccessToken = accessGrant.AccessToken;
ViewBag.ResultText = result.ToString();
return View();
}
The text was updated successfully, but these errors were encountered:
There is one problem with the sample application at CSharp.GitHub / CSharp.GitHub.MVC 3 Example / Controllers / GitHubController.cs:
This is throwing the following Exception:
This is happening because GitHub requires a User-Agent header along with the request. To solve this problem is very easy.
I upgraded to the latest Spring.Social.Core package, which is 4.3.0 as of this writing.
I then modified the above code to an exchange() rather than a GetForObject()
The text was updated successfully, but these errors were encountered: