public static Dictionary <string, object> RefreshToken(string client_id, string client_secret, string refresh_token) { Dictionary <string, object> dataDict = new Dictionary <string, object>(); dataDict.Add("client_id", client_id); dataDict.Add("client_secret", client_secret); dataDict.Add("refresh_token", refresh_token); dataDict.Add("grant_type", "refresh_token"); string res = REST.HttpPost("https://accounts.google.com/o/oauth2/token", dataDict); return((Dictionary <string, object>)CountryCodeTopLevelDomain.DecodeJson(res)); }
/* * function OAuthConnect(client_id, scope, login_hint) { * var url = XMAP("https://accounts.google.com/o/oauth2/auth?[1]&[2]&[3]&[4]&[5]&[6]", * "response_type=code", * "client_id=" + client_id, * "redirect_uri=" + "urn:ietf:wg:oauth:2.0:oob", * "scope=" + escape(scope), * "state=acit", * "login_hint=" + login_hint); * * var oIE = new ActiveXObject("InternetExplorer.Application"); * oIE.Visible = true; * oIE.Navigate(url); * while (oIE.busy) { * WScript.Sleep(10); * }; * var status = oIE.Document.title; * while (status.indexOf("state=acit") === -1) { * WScript.Sleep(100); * status = oIE.Document.title; * } * // WScript.Echo(status); * oIE.Quit(); * var code = RightOf(status, "&code="); * return code; * } */ public static string GetTokens(string client_id, string client_secret, string code) { Dictionary <string, object> dataDict = new Dictionary <string, object>(); dataDict.Add("code", code); dataDict.Add("client_id", client_id); dataDict.Add("client_secret", client_secret); dataDict.Add("redirect_uri", "urn:ietf:wg:oauth:2.0:oob"); dataDict.Add("grant_type", "authorization_code"); string res = REST.HttpPost("https://accounts.google.com/o/oauth2/token", dataDict); return(res); }
public static Dictionary <string, object> RefreshToken(string client_id, string client_secret, string refresh_token) { Dictionary <string, object> dataDict = new Dictionary <string, object>() { { "client_id", client_id }, { "client_secret", client_secret }, { "refresh_token", refresh_token }, { "grant_type", "refresh_token" } }; string res = REST.HttpPost("https://accounts.google.com/o/oauth2/token", dataDict); return((Dictionary <string, object>)DecodeJson(res)); }