I try to send this two requests but I only get as a response the errors listed in the title. My two webrequests to the google servers are like this:
HttpClient http = new HttpClient();
HttpResponseMessage response = await http.GetAsync("https://accounts.google.com/o/oauth2/token?code="+localSettings.Values["AccessKey"]+"&client_id=XX-XXXXXXXXXX.apps.googleusercontent.com&client_secret=XXXXX-XXXX&redirect_uri=http://localhost/oauth2callback&grant_type=authorization_code");
//response.EnsureSuccessStatusCode();
Debug.WriteLine(response.ToString());
HttpResponseMessage response1 = await http.GetAsync("https://content.googleapis.com/youtube/v3/subscriptions?part=id&maxResults=10&mine=true&key="+localSettings.Values["AccessKey"]);
Debug.WriteLine(response1.ToString());
I get the following output from the Debugger:
StatusCode: 405, ReasonPhrase: '', Version: 2.0, Content: System.Net.Http.StreamContent, Headers:
{
server: GSE
alt-svc: quic=":443"; p="1"; ma=604800
cache-control: max-age=0, private
accept-ranges: none
date: Tue, 29 Sep 2015 16:05:03 GMT
x-frame-options: SAMEORIGIN
vary: Accept-Encoding
x-content-type-options: nosniff
alternate-protocol: 443:quic,p=1
x-xss-protection: 1; mode=block
content-type: application/json
expires: Tue, 29 Sep 2015 16:05:03 GMT
}
StatusCode: 400, ReasonPhrase: '', Version: 2.0, Content: System.Net.Http.StreamContent, Headers:
{
server: GSE
alt-svc: quic=":443"; p="1"; ma=604800
cache-control: max-age=0, private
accept-ranges: none
date: Tue, 29 Sep 2015 16:05:04 GMT
x-frame-options: SAMEORIGIN
vary: X-Origin
vary: Origin
vary: Accept-Encoding
x-content-type-options: nosniff
alternate-protocol: 443:quic,p=1
x-xss-protection: 1; mode=block
content-type: application/json; charset=UTF-8
expires: Tue, 29 Sep 2015 16:05:04 GMT
}
localSettings.Values["accessKey"]
in the URLs - is this value correct if you print it out? – Alexisaleycontent
in the URL - try just usinghttps://www.googleapis.com/youtube/v3....
– Alexisaley"
characters in the URLs by prefixing them with a backslash:\"
. – Alexisaley"https://googleapis.com/youtube/v3/subscriptions?part=id&maxResults=10&mine=true&key="+localSettings.Values["AccessKey"]
. – Alexisaleyuser agent
header. I think i remember i had "problems" with google apis when it is not set. (Even it´s not documented) – NysaGET
,POST
,PUT
, etc.). The fix to the first error could be as simple as replacingGetAsync
withPostAsync
. As it stands, the second error appears to be a knock-on of the first having failed. I haven't looked into this in detail but you may need to pull some data out of the response to the first request and pass that to the second. – Acea