/** * Revokamos el Token * **/ public async Task <bool> callLogOut() { SFDCRestApi sfdcRestApi = new SFDCRestApi(); JObject responseObject = await sfdcRestApi.Request("GET", "https://login.salesforce.com/services/oauth2/revoke?token=" + this.AccessToken + "&refresh_token=" + this.RefreshToken, "" ); return(true); }
//TEST Inserta un objeto log en salesforce public async void insertarLog(LogModel log) { //creamos un objeto con los campos que queremos sincronizar var updateLog = new JObject(); updateLog.Add("Tipo_Log__c", log.TipoLog); updateLog.Add("Aplicacion__c", log.App); updateLog.Add("Descripcion__c", log.Descripcion); var sfdcApi = new SFDCRestApi(); var jsonResult = await sfdcApi.Request("POST", "sobjects/LOG__c", updateLog.ToString()); }
public async void obtenerUltimosLogs() { ListaLogs.Clear(); var sfdcApi = new SFDCRestApi(); var jsonResult = await sfdcApi.Request("GET", "query?q=SELECT+id,Aplicacion__c,Tipo_Log__c,Descripcion__c+FROM+LOG__c+ORDER+BY+CreatedDate+desc+limit+100 "); var records = jsonResult["records"]; foreach (var log in records) { ListaLogs.Add(new LogModel { App = log["Aplicacion__c"].ToString(), TipoLog = log["Tipo_Log__c"].ToString(), Descripcion = log["Descripcion__c"].ToString(), }); } }
/** * Refrescamos el access token usando el refresh token. * * Devolvemos true si hemos obtenido correctamente el access token. false e.c.c. **/ public async Task <bool> RefreshTokenFlow() { //si no tenemos refres token no podemos hacer nada if (RefreshToken == null || RefreshToken == "") { return(false); } else { SFDCRestApi sfdcRestApi = new SFDCRestApi(); JObject responseObject = await sfdcRestApi.Request("POST", "https://login.salesforce.com/services/oauth2/token", string.Format("grant_type=refresh_token&client_id={0}&refresh_token={1}", ConsumerKey, RefreshToken)); AccessToken = (string)responseObject["access_token"]; InstanceUrl = (string)responseObject["instance_url"]; return(true); } }
//TEST Inserta un objeto log en salesforce public async void borrarLog(LogModel log) { var sfdcApi = new SFDCRestApi(); var jsonResult = await sfdcApi.Request("DELETE", "sobjects/LOG__c/" + log.Id); }
/** * Revokamos el Token * **/ public async Task<bool> callLogOut() { SFDCRestApi sfdcRestApi = new SFDCRestApi(); JObject responseObject = await sfdcRestApi.Request("GET", "https://login.salesforce.com/services/oauth2/revoke?token=" + this.AccessToken + "&refresh_token=" + this.RefreshToken, "" ); return true; }
/** * Refrescamos el access token usando el refresh token. * * Devolvemos true si hemos obtenido correctamente el access token. false e.c.c. **/ public async Task<bool> RefreshTokenFlow() { //si no tenemos refres token no podemos hacer nada if (RefreshToken == null || RefreshToken == "") { return false; } else { SFDCRestApi sfdcRestApi = new SFDCRestApi(); JObject responseObject = await sfdcRestApi.Request("POST", "https://login.salesforce.com/services/oauth2/token", string.Format("grant_type=refresh_token&client_id={0}&refresh_token={1}", ConsumerKey, RefreshToken)); AccessToken = (string)responseObject["access_token"]; InstanceUrl = (string)responseObject["instance_url"]; return true; } }