Microsoft Graph "Access is denied. Check credentials and try again" in WEBDEV - api

The code below is used to get calendar from my email account through Microsoft Graph. But I keep getting an error. I can get the list of places and user information, but I can´t get the calendar.
I´ve tried this code:
CODE :
gsO365_ClientID est une chaîne = "..."
gsO365_ClientSecret est une chaîne = ".."
dGdO365_ClientSecret_Expiration est une Date = ".."
gsO365_Tenant est une chaîne = ".."
gsO365_URICallBack_WEB est une chaîne = "http://localhost/inscription/WD260AWP/WD260Awp.exe/OAUTH2_RETOUR"
gsO365_URICallBack_WEB_Test est une chaîne = "http://localhost/WD250AWP/WD250Awp.exe/OAUTH2_RETOUR"
sGsO365_URICallBack_APP est une chaîne = ".."
OAuth2Params est OAuth2Paramètres
OAuth2Params..ClientID = gsO365_ClientID
OAuth2Params..URLAuth = "https://login.microsoftonline.com/[%gsO365_Tenant%]/oauth2/v2.0/authorize"
OAuth2Params..URLToken = "https://login.microsoftonline.com/[%gsO365_Tenant%]/oauth2/v2.0/token"
OAuth2Params..ParamètresSupplémentaires = "force_reapprove=false"
OAuth2Params..Scope = "offline_access Calendars.Read"
MonToken est un AuthToken = AuthIdentifie(OAuth2Params)
oRequête est une httpRequête
oRequête.Méthode = httpGet
oRequête.URL = "https://graph.microsoft.com/v1.0/me/calendar/events"
oRequête.ContentType = "application/json"
oRequête.AuthToken = MonToken
Réponse est une httpRéponse
jsRéponse est un JSON
Réponse = HTTPEnvoie(oRequête)
SI ErreurDétectée ALORS
Erreur("La requête HTTP à Office 365 a échouée"+RC+ErreurInfo())
RENVOYER Faux
SINON
jsRéponse = Réponse..Contenu
Trace(Réponse..Contenu)
// Le serveur a renvoyé une erreur
SI jsRéponse.Error..Existe ALORS
Erreur("La requête à Office 365 a échouée"+RC+jsRéponse.Error.Message)
SINON
Trace(jsRéponse)
FIN
FIN

Are you sure you add the follow autorisations on the API permissions page :
Calendars.Read, Calendars.ReadWrite

Related

insertion dans une base de données Rpostgres [closed]

Closed. This question is not written in English. It is not currently accepting answers.
Stack Overflow is an English-only site. The author must be able to communicate in English to understand and engage with any comments and/or answers their question receives. Don't translate this post for the author; machine translations can be inaccurate, and even human translations can alter the intended meaning of the post.
Closed 5 days ago.
Improve this question
Bonjour à tous, je vous écris ici car j'ai un soucis j'apprend a utiliser R et Postgres je ne sais pas si je suis au bon endroit .
j'ai importé plusieurs fichiers cvs dans R et j'ai essayé d'inserer leurs données dans Postgres . La première insertion a marché
mais toutes les autres tentatives d'enregistrement ne marchent pas.
files<-scale
files
# INSERTION DANS LA BASE DE DONNEES
# Pour chaque ligne de données
for (i in 1:nrow(files)) {
# Vérification si la ligne existe déjà dans la table
result <- dbGetQuery(con, paste0("SELECT * FROM scale WHERE scale_code = '",
files[i,1], "' " ))
# Si la ligne n'existe pas déjà, l'insérer
if (nrow(result) == 0) {
dbGetQuery(con, paste0("INSERT INTO scale (scale_code, scale_name, scale_type, scale_level) VALUES ('",
files[i,1], "', '",files[i,2], "','",files[i,3], "','",files[i,4], "' )"))
}
}
je n'ai aucune erreur mais en consultant la table scale aucune données n'est ajoutée. Que faire?

Display a message between a date range in velocity language

I want to display a message between a date range in Velocity language. Like from 1/3/2023 to 23/3/2023. How can I do that.
I tried to put condition but it's not working.
#set($user = SpermissionChecker.getUser() if (Guser.female)
#set($genre = "Madame")
#else
#set($genre = "Monsieur")
#end
#get (fact-Suser.getExpandoBridge ().getAttribute("active_"))
if("$/act"=="RESILIE"}
Suite à la résiliation de votre contrat, l'acces
contenu est limité à 6 mois, nous vous conseillons de sauvegarder vos documer
#set ($timete dateUtil.getCurrentDate ("dd/MM/yyyy", Locale))
#end
#if($timet =="03/12/2022" && $timet =="10/12/2022")
Rapprochement des banques du Groupe Crédit du Nord et portail et votre application mobile Santé évoluent </span

GAS Spreadsheet script to create and open / download Drive PDF in Custom Dialog

Good morning, I have some scripts with which I save a PDF file in a specific folder and then send it by email. Everything works fine, even if my code is not optimized. Recently I put a previous query where they helped me how to create a Custom Dialog to show the link to download the PDF file, however when I click on the link I automatically get error 400 which makes it impossible for me to download that PDF. I still cannot determine what I am failing, besides that, I would like the PDF to be displayed in the Custom Dialog. The code:
function CrearPDF(){
var spreadsheet = SpreadsheetApp.getActive();
var nombreHoja = 'LP con Seguros';
var sheet = spreadsheet.getSheetByName(nombreHoja).activate();
var gid = sheet.getSheetId()
var fecha = Utilities.formatDate(new Date(), "GMT-5", "dd/MM/yyyy HH:mm:ss");//Captura de la fecha de acuerdo a la zona horaria
var dni = spreadsheet.getRange('\'LP con Seguros\'!B1').getValues();
var nrocuenta = spreadsheet.getRange('\'LP con Seguros\'!C6').getValues();
var correo = spreadsheet.getRange('\'LP con Seguros\'!K13').getValues();
var valRegisSimul=spreadsheet.getRange('\'LP con Seguros\'!P10').getValues();
var nombrePDF = valRegisSimul + " de LP DNI "+dni+" " +fecha+".pdf";
var ssID = spreadsheet.getId();
var url = "https://docs.google.com/spreadsheets/d/"+ssID+"/export"+
"?format=pdf&"+
"size=a4&"+
"portrait=true&"+
"scale=4&"+
//"top_margin=0.40&"+
//"bottom_margin=0.40&"+
//"left_margin=0.40&"+
//"right_margin=0.40&"+
"gridlines=false&"+
"printnotes=false&"+
//"pageorder=2&"+
"horizontal_alignment=CENTER&"+
"vertical_alignment=TOP&"+
"printtitle=false&"+
"sheetnames=false&"+
"fzr=false&"+
"fzc=false&"+
"attachment=false&"+
"gid=" + gid + "&"+
"r1=" + 0 + "&"+
"c1=" + 0 + "&"+
"r2=" + 62 + "&"+
"c2=" + 8;
var params = {method:"GET",headers:{"authorization":"Bearer "+ ScriptApp.getOAuthToken()}};
var response = UrlFetchApp.fetch(url, params).getBlob();
// Creamos un fichero con el Blob anterior y le cambiamos el nombre
var token = ScriptApp.getOAuthToken();
var docurl = UrlFetchApp.fetch(url, { headers: { 'Authorization': 'Bearer ' + token } });
var pdf = docurl.getBlob().setName(nombrePDF).getAs('application/pdf');
var folders = DriveApp.getRootFolder().getFolders(); // En esta variable se almacenan solo los carpetas del directorio raiz
var nombrecarpeta = "DNIs de LP y Simulaciones";
if(folders.hasNext() == false)//Para cuando no hay carpetas o folder aún en el Drive
{
var NewFolder = DriveApp.createFolder(nombrecarpeta);
NewFolder.createFile(pdf);
var file = NewFolder.createFile(pdf);
Logger.log(file.getDownloadUrl());
}
else //En el caso de que sí haya carpetas o folder en el Drive, los recorre hasta encontrar el nombre "nombrecarpeta" sino lo encuentra la creará y ahí guarda el archivo
{
while (folders.hasNext())
{
var folder = folders.next();
if(folder.getName() == nombrecarpeta)// en el caso de que exista una carpeta con el nombre terminamos la iteracion de las carpetas
{
var folderid = folder.getId();
var Transfolder = DriveApp.getFolderById(folderid);
Transfolder.createFile(pdf);
var file = Transfolder.createFile(pdf);
Logger.log(file.getDownloadUrl());
break;
}
else
{// Creamos la carpeta en el caso de que aún no exista y guardamos el archivo en la nueva carpeta
var NewFolder = DriveApp.createFolder(nombrecarpeta);
NewFolder.createFile(pdf);
var file = NewFolder.createFile(pdf);
Logger.log(file.getDownloadUrl());
break;
}
}
}
spreadsheet.setActiveSheet(spreadsheet.getSheetByName('LP con Seguros'), true);
var sheet = spreadsheet.getActiveSheet();
//Obtiene el nombre del archivo PDF recién creado, así como su contenido
var archivo = docurl.getBlob().getAs('application/pdf').getBytes(); // sin la opción getBytes obtendríamos un archivo sin contenido
var attach = {fileName:nombrePDF,content:archivo, mimeType:'application/pdf'};
var subject = valRegisSimul + ' de Crédito Efectivo DNI ' + dni + ' ' + fecha;
var html = '<body>' + '<strong>' + ' <p>Estimado(a)' + '</strong>' + '</p>' +
'<p>A continuación encontrará adjunto el archivo del plan de pagos de su Crédito Efectivo, recuerde siempre realizar los abonos al número de cuenta del préstamo.</p>' +
'<p style="text-align: left;">==> El número de cuenta del Crédito Efectivo a donde se deben hacer los abonos es: ' + '<strong>' + nrocuenta + '</strong>' + '</p>'
//Muestra un Popup preguntando si deseas enviar la transferencia por correo
SpreadsheetApp.getUi()
var ui = SpreadsheetApp.getUi();
var response = ui.alert('Se completó el registro correctamente, ¿Desea enviar el plan de pagos al correo registrado: '+ correo + ' ?' + '\n\n' + 'Caso contrario, el archivo ' + nombrePDF + ' sólo se guardará en la carpeta ' + nombrecarpeta + ' de Drive', ui.ButtonSet.YES_NO);
// Si la respuesta es si, mandará el correo, de lo contrario termina el programa
if (response == ui.Button.YES)
{
GmailApp.sendEmail(correo, subject, "Cuerpo", {htmlBody:html, attachments:[attach]});
SpreadsheetApp.getUi().alert('Se envió correctamente el plan de pagos al correo '+ correo + '.' + '\n\n' + 'Mencione regreso por seguros y número de cuenta del Crédito efectivo');
}else
{
//Solo por referencia
Logger.log('El archivo '+ nombrePDF + ' quedó guardado en la carpeta ' + nombrecarpeta + ' de Drive');
};
var url = file.getDownloadUrl();
var html = 'Para descargar el PDF con la simulación de pagos, haz clic aquí';
var userInterface = HtmlService.createHtmlOutput(html);
var title = "Descargar PDF de Google Drive";
SpreadsheetApp.getUi().showModalDialog(userInterface, title);
}
Custom Dialog Error 400
Thanks in advance for the answers I will receive.
Thanks to #Adam Stevenson for the support, I corrected the code, however I still can't download the PDF, now I get a different error. Attachment screenshot.
Error after correcting the code
When you define html:
var html = 'Para descargar el PDF con la simulación de pagos, haz clic aquí';
…you did not break up the string with single quotes '. The double quote " does not end the string since you started it with single quotes. So + url + is just being read as part of the string. The corrected code:
var html = 'Para descargar el PDF con la simulación de pagos, haz clic aquí';

Threading App crash ntdll.dll every 2 or 3 days

I have an app running on a client machine, that uses threading, and is working fine, until the problem arrives.
The app crash every 2 or 3 days, and I have to restart it.
This is the error information I can get from the Event Viewer on the client machine.
Nombre de la aplicación con errores: SEM.CCQ.exe, versión: 1.15.0.0, marca de tiempo: 0x5b4488d8
Nombre del módulo con errores: ntdll.dll, versión: 6.1.7601.24094, marca de tiempo: 0x5abee643
Código de excepción: 0xc0000374
Desplazamiento de errores: 0x00000000000bf6b2
Id. del proceso con errores: 0x18700
Hora de inicio de la aplicación con errores: 0x01d41a9f081a1380
Ruta de acceso de la aplicación con errores: C:\SEM.CCQ\SEM.CCQ.exe
Ruta de acceso del módulo con errores: C:\Windows\SYSTEM32\ntdll.dll
Id. del informe: 1fa3b455-8919-11e8-9638-ec8eb5708651
It's crazy to try to locate the problem. Don't know how to start as the problem is not coming very often.
Is there any way to debug/catch this kind of problem to try to solve it?
Any help will be appreciated.

How can i display multiple views with ModuleFrontController in PS 1.6

With my Module Front Controller, i need to initialize it to display a form (formulaire.tpl) that the customer has to fill. Then the controller processes the data posted from the form using methods defines in my model (Formulaire.php) and then i would like to make it display another view (recapitulatif.tpl) that displays a reminder of data sent, an add to cart button for example or the possibility to fill the form in again.
As i would like to implement it the MVC way, i don't want to create a new php page to redirect my customer to but i would like to display somehow this second template after processing the data. Is there any way to do so with the controller? Here below, you can find my code, it doesn't work and it displays my first template and below my second..
class FormulaireModuleDefaultModuleFrontController extends ModuleFrontController
{
public $ssl = true;
private $done_traitement = false;
public function postProcess()
{
//On vérifie le bouton submit du formulaire
if(Tools::isSubmit('bouton'))
{
// On va commencer en premier par récupérer l'id customer avec la variable cookie
// et vérifier que la personnes est bien loggée
global $cookie;
if(!isset($cookie->id_customer))
{
$message='Aucun client loggé';
}
else
{
$errors=array();
$id_cart=$this->context->cart->id;
$customer=$cookie->id_customer;
//On récupère les valeurs du formulaire
$prix=Tools::getValue('resultat');
$titre='porte_test';
$desc='Largeur de passage de '.Tools::getValue('largeur_passage').' mm, hauteur de passage de '.Tools::getValue('hauteur_passage')
.' mm, hauteur de linteau de '.Tools::getValue('hauteur_linteau').' mm, ecoinçon gauche de '.Tools::getValue('ecoincon_gauche')
.' mm, ecoincon_droit de '.Tools::getValue('ecoincon_droit'). ' mm, motif en '.Tools::getValue('motif_porte').' et de couleur '
.Tools::getValue('couleur_porte');
//On va vérifier les champs obligatoires
//Les champs sont remplis, on va faire le traitement des données.
$idprod=Formulaire::creerProduct($titre,0,13,$prix,$desc, 'mod_100',$customer);
Formulaire::addProduitauPanier($idprod);
$this->done_traitement=true;
}
//On envoie le message si il existe:
if(isset($message))self::$smarty->assign('message',$message);
if(isset($errors))self::$smarty->assign('erreurs',$errors);
}
}
public function initContent()
{
parent::initContent();
if($this->done_traitement)
$this->display(__FILE__,'recapitulatif.tpl');
}
public function init(){
$this->display_column_left = false;
$this->display_column_right = false;
$this->page_name = 'Configurateur';
parent::init();
$this->setTemplate('formulaire.tpl');
}
}
Thanks in advance for your help !
EDIT :
Ok sorry for the question. It just took me 2 minutes to figure it out after posting the question. I only needed to change:
$this->display(__FILE__,'recapitulatif.tpl');
by :
$this->setTemplate('recapitulatif.tpl');
And now it works. Sorry for the inconvenience !