private static Token GetToken(string code) { var data = string.Format("code={0}&client_id={1}&client_secret={2}&grant_type=authorization_code", HttpUtility.UrlEncode(code), HttpUtility.UrlEncode(ClientId), HttpUtility.UrlEncode(SecretKey)); var jsonToken = RequestHelper.PerformRequest(BoxUrlToken, "application/x-www-form-urlencoded", "POST", data); Global.Logger.Debug("BoxApp: token response - " + jsonToken); return(Token.FromJson(jsonToken)); }
public Token RefreshToken(string refreshToken) { Global.Logger.Debug("BoxApp: refresh token"); var query = String.Format("client_id={0}&client_secret={1}&refresh_token={2}&grant_type=refresh_token", HttpUtility.UrlEncode(ClientId), HttpUtility.UrlEncode(SecretKey), HttpUtility.UrlEncode(refreshToken)); var jsonToken = RequestHelper.PerformRequest(BoxUrlToken, "application/x-www-form-urlencoded", "POST", query); Global.Logger.Debug("BoxApp: refresh token response - " + jsonToken); var token = Token.FromJson(jsonToken); if (token != null) { Token.SaveToken(AppAttr, token); } return(token); }
private static Token GetToken(string code) { var data = string.Format("code={0}&client_id={1}&client_secret={2}&redirect_uri={3}&grant_type=authorization_code", HttpUtility.UrlEncode(code), HttpUtility.UrlEncode(ClientId), HttpUtility.UrlEncode(SecretKey), RedirectUrl); try { var jsonToken = RequestHelper.PerformRequest(GoogleUrlToken, "application/x-www-form-urlencoded", "POST", data); Global.Logger.Debug("GoogleDriveApp: token response - " + jsonToken); return(Token.FromJson(AppAttr, jsonToken)); } catch (Exception ex) { Global.Logger.Error(ex); } return(null); }
private OAuth20Token DecryptToken(string token) { return(string.IsNullOrEmpty(token) ? null : Token.FromJson(InstanceCrypto.Decrypt(token))); }