So I wrote another post method to get a renew token, however I am getting error "(400) Bad Request.".
is it because the application I defined as a "web application" (I got my first accesstoken from the call back link) not "Installed Application" ?
public GoogleAccessTokenData GetAccessTokenDataFromRefreshToken(string authorizationCode, string refreshToken)
{
string data = "code={0}&client_id={1}&client_secret={2}&refresh_token={3}&grant_type=refresh_token";
HttpWebRequest request = HttpWebRequest.Create(Url) as HttpWebRequest;
string result = null;
request.Method = "POST";
request.KeepAlive = true;
request.ContentType = "application/x-www-form-urlencoded";
string param = string.Format(data, authorizationCode, _GoogleClientId, _GoogleSecret, refreshToken);
var bs = Encoding.UTF8.GetBytes(param);
using (Stream reqStream = request.GetRequestStream()) <=== exception thrown with error "(400) Bad Request"
{
reqStream.Write(bs, 0, bs.Length);
}
using (WebResponse response = request.GetResponse())
{
var sr = new StreamReader(response.GetResponseStream());
result = sr.ReadToEnd();
sr.Close();
}
var jsonSerializer = new JavaScriptSerializer();
var tokenData = jsonSerializer.Deserialize<GoogleAccessTokenData>(result);
return tokenData;
}