Using MailApp sendEmail in shared application - email

I have an google web app that uses the send mail function, it works but when users use it, emails are sent automatically from my account, I want to know if there is a possibility that emails are sent from the account who uses the app.
I initially deployed the application by setting it :
Execute the app as : Me (my account)
Who has access to the app : Any member of company domain
I later reconfigured the application as follows
Execute the app as : User accessing the web app
Who has access to the app : Any member of company domain
Other permissions were then requested to users, everyone naturally accepted, but the application blocks.

This definitely should be possible, because there are lots of applications like Outreach.io, Hubspot, Autopilot, and FrontApp that have users connect their G Suite account in order to use that infrastructure for sending.
Can you further explain what you mean by "the application blocks"?
What happened regarding the email send once you made the changes to send from the User accessing the Web App? Was there no change or did it throw an error?
Do you have a copy of the email in your G Suite or Gmail inbox that was sent via the Web App? If so can you go to "Show Original" and copy paste the header information into this thread? This info will allow me to quickly assess a little more information about the sending infrastructure. Be aware that the "Show Original" information cannot be from a forwarded email.
Peace,
-LB

There was an unused library that was hanging in the project, also the fact that I could not empty the some manifest file,
So I deleted the entire project from the cloud, and I redid the script again, being very careful about everything I did,
Finally I shared the application, and users were finally able to send emails, which were sent from their own accounts,
I thank you very much for your intervention, you were right, I put the entire script online, it can be useful for others,
I just specify that the script pick data from the sheet, puts it in a table, and adds a signature with animated gif images,
function sendemail(id) {
var rw = parseInt(id);
var agent = Session.getActiveUser().getEmail();
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Saisie");
var des = sheet.getRange(rw,8).getValue();
var eml = sheet.getRange(rw,9).getValue();
var dat = Utilities.formatDate(new Date(), "Europe/Paris", "dd/MM/yyyy");
var typ = sheet.getRange(rw,5).getValue();
var nbo = sheet.getRange(rw,6).getValue();
var obj = sheet.getRange(rw,7).getValue();
var num = sheet.getRange(rw,4).getValue();
var soc = sheet.getRange(rw,11).getValue();
var nom = sheet.getRange(rw,12).getValue();
var adr = sheet.getRange(rw,13).getValue();
var vil = sheet.getRange(rw,14).getValue();
var pay = sheet.getRange(rw,15).getValue();
var company = DriveApp.getFileById('abcd').getBlob().setName("company");
var departement = DriveApp.getFileById('abcd').getBlob().setName("company");
var userName = getUserInfo(agent);
var msg = '<html><head><meta charset="utf-8">' +
'<style>table{border-collapse:collapse;}td{border: 1px solid black;padding-left:4px;}.tete{background-color:#f6f6f6;text-align:center;}.titre {background-color:#ebffce;}</style>' +
'</head><body>Bonjour,<br><br><table style="width:100%;"><tr><td colspan="2" class="tete">Réception d&apos;objet à l&apos;attention de « <span style="color:#0900c6;">'+ des + '</span> »</td></tr>' +
'<tr><td width="140" width class="titre">Date de réception</td><td>'+ dat +'</td></tr>' +
'<tr><td class="titre">Objet & Nombre</td><td>'+ obj + ' - ' + nbo + '</td></tr>' +
'<tr><td class="titre">Type Transport</td><td>'+ typ + '</td></tr>' +
'<tr><td class="titre">N° Transport</td><td>'+ num +'</td></tr>' +
'<tr><td colspan="2" class="tete">Info Expéditeur</td></tr>' +
'<tr><td class="titre">Société</td><td>'+ soc +'</td></tr>' +
'<tr><td class="titre">Collaborateur</td><td>'+ nom +'</td></tr>' +
'<tr><td class="titre">Adresse</td><td>'+ adr +'</td></tr>' +
'<tr><td class="titre">Ville - Pays</td><td>'+ vil + ' ' + pay + '</td></tr></table><br>' +
'Cordialement, '+ userName +' - Service Courrier.<br><br>' +
'<table style="border-collapse:collapse;"><tr>' +
'<td rowspan="2" style="text-align:center;border: 1px solid black;"><img src="cid:logocompany"></td>' +
'<td style="text-align:center;border: 1px solid black;"><img src="cid:logodepartement"></td>' +
'</tr><tr><td style="text-align:center;border: 1px solid black;padding:4px;"><div style="text-align:center;">' +
'12 Place de la République - 75123 Paris Cedex 10<br>Tél. : 02 44 44 44 44 - Fax : 02 55 55 55 55<br>Email : '+agent+'</div></td></tr></table></body></html>';
MailApp.sendEmail({
to: eml,
subject: "Message Automatique Service Courrier",
htmlBody: msg,
inlineImages:{
logocompany: company,
logodepartement:departement
}
});
}

Related

Integrating Driverless AI with Anylogic Simulation, MOJO Pipeline error

I am trying to integrate Driverless AI in my Anylogic Simulation project, but am unable to make the mojo pipeline work. I have placed the license.sig file in the same directory as mojo pipeline. The license.sig file I am using has been created using a text file of the license key, hope that is not a problem here. The error I am getting is "Model cannot be resolved"
Below is the code I used to run MOJO:
MojoFrameBuilder fb = stayDurationModel.getInputFrameBuilder();
MojoRowBuilder rb = fb.getMojoRowBuilder();
rb.setString("ORG", ORG);
rb.setString("Org_Product", Org_Product);
rb.setString("Org_Region", Org_Region);
rb.setDate("Due Date", new java.sql.Date(Due_Date.getTime()));
rb.setString("Customer Name", Customer_Name);
rb.setDouble("Invoice Amount", Invoice_Amount);
rb.setString("Bank Account Name", Bank_Account_Name);
fb.addRow(rb);
MojoFrame iframe = fb.toMojoFrame();
MojoFrame oframe = DSOModel.transform(iframe);
// Extract output from frame:
String[] outputArray = oframe.getColumn(0).getDataAsStrings();
double DSO = Double.valueOf(outputArray[0]);
lblPatientTxt.setText("Invoice(\n ORG: " + ORG + ",\n Org_Product: " +
Org_Product + ",\n Due Date " + Due_Date + ",\n Invoice Amount" +
Invoice_Amount + ",\n Customer Name " + Customer_Name + ",\n Bank Account
Name"
+ Bank_Account_Name + ")");
lblBedDays.setText("DSO" + DSO + " days");
stayDurationDS.add(DSO);
return DSO;
Have attached the console error logs and the code. Thanks in advance!
Console Error Message

FabricJS Android Webview Newlines showing as \n

So I load a basic page with the canvas and everything seems to work except newlines are shown as \n
here is the body as a java method:
input = StringEscapeUtils.unescapeShell(this.getData());
private String htmlBody(String input){
return "<html><head>" +
"<link href=\"fonts.css\" type=\"text/css\" rel=\"stylesheet\" />" +
"<script src=\"jquery.min.js\" type=\"text/javascript\"></script>" +
"<script src=\"fontfaceobserver.js\" type=\"text/javascript\"></script>" +
"<script src=\"fabric.min.js\" type=\"text/javascript\"></script>" +
"<style type=\"text/css\">" +
".canvas-container {" +
"margin: 0 auto;" +
"}"+
"</style>" +
"<script src=\"javascript_fabric.js\" type=\"text/javascript\"></script>" +
"</head><body>"+
"<div id=\"sb2div\" class=\"row\" style=\"margin: 0 auto!important; max-height: 100vh\">" +
"<canvas id=\"fabricjs-branding\" width=\"600\" height=\"600\" style=\"margin: auto!important;\"></canvas>" +
"</div>" +
"<script>" +
"$(document).ready(function(){" +
"setUpBranding();" +
"var o = " + input + ";" +
"console.log(o);" +
"fabricjscanvas.loadFromJSON(o);"+
"});" +
"</script>" +
"</body></html>";
}
setUpBranding() does my initialization of fabricjscanvas which does add some feature prototypes but the issue has nothing to do with them.
itext and textbox are standard using the current release 4
on the desktop using the same setup everything is fine...
based on a comment i found the newline characters were not getting unescaped with the rest of the json data... strange but I was able to fix it using the Java String Replace method... after using the StringEscapeUtils.unescapeShell
input = StringEscapeUtils.unescapeShell(this.getData());
input = input.replace("\\\\n", "\\n");

How-to: Setup Azure Push Notification with Client SDK v3.1.0 and Server SDK v2.0.0 using a CustomAuthController

Since a few days the new Azure Server and Client SDK are available. I had that issue with the App Service Push https://github.com/Azure/azure-mobile-apps-net-server/issues/170#issuecomment-262656329 in last November 2016.
After reading the release blog https://blogs.msdn.microsoft.com/appserviceteam/2017/01/10/azure-mobile-apps-net-sdk-releases/ I can now see that the current
way to register for push notification is deprecated.
Can you please give me detailed instructions what I have to change to use the new App Service Push?
The previous problem was that the
_UserId (SID)
Tag was not properly included in the push notification installation. The _UserId had the MD5 hash of the NameIdentifier instead of the clients unique Id I passed to the CustomAuthController. But I need my clients unique Id afterwards for targeted push notifications to clients utilizing the
_UserId=client-unique-id
Here is my current code in Android:
protected override void OnRegistered(Context context, string registrationId)
{
Log.Verbose("PushHandlerBroadcastReceiver", "GCM Registered: " + registrationId);
App.NotificationHubInstallationId = registrationId;
//await RegisterForPushNotifications(OfflineSyncStoreManager.Instance.MobileAppClient, MainActivity.CurrentActivity);
MainActivity.CurrentActivity.RunOnUiThread(async () =>
{
if (GcmClient.IsRegistered(context))
{
try
{
var pushHub = OfflineSyncStoreManager.Instance.MobileAppClient.GetPush();
const string templateBodyGcm = "{\"data\":{\"message\":\"$(messageParam)\"}}";
var templates = new JObject
{
["genericMessage"] = new JObject
{
{"body", templateBodyGcm}
}
};
//NOTE: Unregister any previous NotificationHub Installation of the TruckerApp on that device
await pushHub.UnregisterAsync().ConfigureAwait(false);
//NOTE_ Register the TruckerApp for Push Notification in the backend.
await pushHub.RegisterAsync(registrationId, templates).ConfigureAwait(false);
MetricsManager.TrackEvent($"PushNotificationHub-{OfflineSyncStoreManager.Instance.MobileAppClient.CurrentUser.UserId}",
new Dictionary<string, string>
{
{"NotificationHubInstallationId", registrationId}
},
new Dictionary<string, double>());
Log.Info("Push Installation Id", App.NotificationHubInstallationId);
}
catch (Exception ex)
{
await MetricsManagerHelper.Instance.SendErrorToApplicationInsightsAsync($"PushNotificationHub Registration failed for reason: {ex.Message}");
DialogNotify("AZURE PUSH Registierungsfehler", "Pushmeldungen sind derzeit nicht verfügbar. " + Environment.NewLine + Environment.NewLine +
"Um neue Aufträge auf Ihr Handy zu übertragen ziehen " +
"Sie bitte in der Truck Auftrag Übericht (hier!) " +
"mit dem Finger von OBEN -> nach -> UNTEN." +
Environment.NewLine +
Environment.NewLine);
}
}
else
{
await MetricsManagerHelper.Instance.SendErrorToApplicationInsightsAsync("GCM/FCM Client is not registered at Google");
DialogNotify("GCM/FCM Push Registrierungsfehler", "Sei konnten nicht beim Google Cloud Messaging angemeldet werden. " +
"Versuchen Sie bitte ein ReLogin oder um neue Aufträge " +
"auf Ihr Handy zu übertragen, ziehen " +
"Sie bitte in der Truck Auftrag Übericht (hier!) " +
"mit dem Finger von OBEN -> nach -> UNTEN." +
Environment.NewLine +
Environment.NewLine);
}
});
}
Here is my current code in iOS:
// We've successfully registered with the Apple notification service, or in our case Azure
public override async void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
{
try
{
const string templateBodyApns = "{\"aps\":{\"alert\":\"$(messageParam)\"}}";
JObject templates = new JObject();
templates["genericMessage"] = new JObject
{
{"body", templateBodyApns}
};
// Register for push with your mobile app
Push push = OfflineSyncStoreManager.Instance.MobileAppClient.GetPush();
await push.RegisterAsync(deviceToken, templates);
}
catch (Exception e)
{
UIAlertView avAlert = new UIAlertView("AZURE PUSH Registierungsfehler",
"Pushmeldungen sind derzeit nicht verfügbar. " +
Environment.NewLine +
Environment.NewLine +
"Um neue Aufträge auf Ihr Handy zu übertragen ziehen " +
"Sie bitte in der Truck Auftrag Übericht (hier!) " +
"mit dem Finger von OBEN -> nach -> UNTEN." +
Environment.NewLine +
Environment.NewLine,
null,
"OK",
null);
avAlert.Show();
}
}
Thanks in advance,
Eric
You don't need to unregister and then register - a simple register will do it.
Check out chapter 5 of the book - http://aka.ms/zumobook - there is code within the chapter for each type of push registration that covers the Installation method (where you specify tags and templates together). You can then specify the SID explicitly by constructing a tag that is suitable for your needs.
One save way is to use the Azure Mobile Client installationId, persist it in your backend and use that Id for targeted push notifications to that individual client. Instead sending the push notification to _UserId:your-userid post to $installationId:your-clients-zumo-client-id
But that requires you to store the installationId in your backend SQL Server or other cache (e.g. Redis)
A better solution is to follow both links below:
General App Service Push Notification Installations ZUMO Book
and for custom push notification Tags that Custom Tag Blog

Qlikview Macro VBScript to print pdf and email will not run consistently - Fails in email

I have been tearing my hair out over the last few days in trying to get this macro to work consistantly on the Windows scheduler.
Basically the workflow is as follows:
1) Windows Scheduler - Daily, uses Admin user credentials
2) Batch file - Reloads using /l
3) Reloads Qlikview application, which has triggers on post reload to save a pdf and email it using PDF Xchange and an html formatted e-mail to cover mobile.
I am getting such inconsistent behaviour that I cannot isolate the problem to any particular one thing. Sometimes it works, sometimes it doesn't. More often than not it fails on the Windows scheduler. There is no error since QV has just thrown up the VBScript window in the hidden process.
I've been changing permissions, which helped me reach a level of inconsistent performance as opposed to no performance.
In addition, it appears that you cannot pass variables to the PDF Xchange printer.
The code in the macro is as follows:
sub ExportPDF
printReportPDF "\\SGH-SRV-FPS1\S-Drive\eCommerce\Data Analyst\Reporting\Daily E-Commerce Report\E-Commerce Daily Report.pdf"
ActiveDocument.GetApplication.Sleep 2000
ActiveDocument.PrintReport "RP01", "PDF-XChange 3.0"
ActiveDocument.GetApplication.Sleep 8000
end sub
Function printReportPDF(pdfOutputFile)
Set WSHShell = CreateObject("WScript.Shell")
WSHShell.RegWrite "HKCU\Software\Tracker Software\PDF-XChange 3.0\OutputFile", pdfOutputFile, "REG_SZ"
WSHShell.RegWrite "HKCU\Software\Tracker Software\PDF-XChange 3.0\BypassSaveAs", "1", "REG_SZ"
Set WSHShell = nothing
End function
Sub ExportEmail
Dim strvDest 'as string
strvDest = ActiveDocument.Variables("vDestination").GetContent().String
msgbox(strvDestination)
Define report variables
get the date as a serial for the filename output
Export an Object
Set obj = ActiveDocument.ActiveSheet.SheetObjects("TX25")
Set obj1 = ActiveDocument.ActiveSheet.SheetObjects("TX17")
Set obj2 = ActiveDocument.ActiveSheet.SheetObjects("TX18")
Set obj3 = ActiveDocument.ActiveSheet.SheetObjects("TX15")
Set obj5 = ActiveDocument.ActiveSheet.SheetObjects("CH62")
Set obj6 = ActiveDocument.ActiveSheet.SheetObjects("TX16")
Set obj8 = ActiveDocument.ActiveSheet.SheetObjects("CH58")
Set obj9 = ActiveDocument.ActiveSheet.SheetObjects("TX31")
Set obj10 = ActiveDocument.ActiveSheet.SheetObjects("CH69")
msgbox("defined objects")
obj.ExportBitmapToFile "D:\QlikView\SGP-UDA\QVS_Source\UserApp\MainLogo.jpg"
obj1.ExportBitmapToFile "D:\QlikView\SGP-UDA\QVS_Source\UserApp\MainHeader.jpg"
obj2.ExportBitmapToFile "D:\QlikView\SGP-UDA\QVS_Source\UserApp\DateRange.jpg"
obj3.ExportBitmapToFile "D:\QlikView\SGP-UDA\QVS_Source\UserApp\SecondaryHeader.jpg"
obj5.ExportBitmapToFile "D:\QlikView\SGP-UDA\QVS_Source\UserApp\DailySiteDetail.jpg"
obj6.ExportBitmapToFile "D:\QlikView\SGP-UDA\QVS_Source\UserApp\SecondaryHeader2.jpg"
obj8.ExportBitmapToFile "D:\QlikView\SGP-UDA\QVS_Source\UserApp\WeeklySiteDetail.jpg"
obj9.ExportBitmapToFile "D:\QlikView\SGP-UDA\QVS_Source\UserApp\SecondaryHeader3.jpg"
obj10.ExportBitmapToFile "D:\QlikView\SGP-UDA\QVS_Source\UserApp\WeeklySiteDetailLW.jpg"
msgbox("created objects")
Dim objEmail
Const cdoSendUsingPort = 2 Send the message using SMTP
Const cdoAnonymous = 0 Do not authenticate
Const cdoBasic = 1 basic (clear-text) authentication
Const cdoNTLM = 2 NTLM
Const SMTPServer = "xxxx" ' changed for public consumption
Const SMTPPort = 25 ' Port number for SMTP
Const SMTPTimeout = 120 ' Timeout for SMTP in seconds
Set objEmail = CreateObject("CDO.Message")
Set objConf = objEmail.Configuration
Set objFlds = objConf.Fields
With objFlds
———————————————————————
SMTP server details
removed the html links down to this being my first post
.Update
———————————————————————
End With
allow the passing of a variable from the load script to define the distribution list
if len(strvDest) > 0 then
msgbox("variable exists "&strvDest)
objEmail.To = strvDest
else
msgbox("variable does not exist")
objEmail.To = "xxxx" 'changed for public consumption
end if
objEmail.From = "xxxx" 'changed for public consumption
objEmail.Subject = "Daily Reporting"
HTML = "<!DOCTYPE HTML PUBLIC ""-//IETF//DTD HTML//EN"">" & chr(13) & chr(10)
HTML = HTML & "<html>"
HTML = HTML & "<head>"
HTML = HTML & "<meta http-equiv=""Content-Type"" content=""text/html; charset=iso-8859-1"">"
HTML = HTML & "<title>Automated Emails!</title>"
HTML = HTML & "</head>"
HTML = HTML & "<body bgcolor=""#FFFFFF"">"
HTML = HTML & "<br> <img src=""cid:MainLogo.jpg"" >"
HTML = HTML & "<br> <img src=""cid:MainHeader.jpg"" >"
HTML = HTML & "<br> <img src=""cid:DateRange.jpg"" >"
HTML = HTML & "<br> <img src=""cid:SecondaryHeader.jpg"" >"
HTML = HTML & "<br> <img src=""cid:DailySiteDetail.jpg"" >"
HTML = HTML & "<br> <img src=""cid:SecondaryHeader2.jpg"" >"
HTML = HTML & "<br> <img src=""cid:WeeklySiteDetail.jpg"" >"
HTML = HTML & "<br> <img src=""cid:SecondaryHeader3.jpg"" >"
HTML = HTML & "<br> <img src=""cid:WeeklySiteDetailLW.jpg"" >"
HTML = HTML & "<p>"
HTML = HTML & "</p>"
HTML = HTML & "</body>"
HTML = HTML & "</html>"
Set objBP = objEmail.AddRelatedBodyPart("D:\QlikView\SGP-UDA\QVS_Source\UserApp\MainLogo.jpg", "MainLogo.jpg", CdoReferenceTypeName)
objBP.Fields.Item("urn:schemas:mailheader:Content-ID") = "<MainLogo.jpg>"
objBP.Fields.Update
Set objBP1 = objEmail.AddRelatedBodyPart("D:\QlikView\SGP-UDA\QVS_Source\UserApp\MainHeader.jpg", "MainHeader.jpg", CdoReferenceTypeName)
objBP1.Fields.Item("urn:schemas:mailheader:Content-ID") = "<MainHeader.jpg>"
objBP1.Fields.Update
Set objBP2 = objEmail.AddRelatedBodyPart("D:\QlikView\SGP-UDA\QVS_Source\UserApp\DateRange.jpg", "DateRange.jpg", CdoReferenceTypeName)
objBP2.Fields.Item("urn:schemas:mailheader:Content-ID") = "<DateRange.jpg>"
objBP2.Fields.Update
Set objBP3 = objEmail.AddRelatedBodyPart("D:\QlikView\SGP-UDA\QVS_Source\UserApp\SecondaryHeader.jpg", "SecondaryHeader.jpg", CdoReferenceTypeName)
objBP3.Fields.Item("urn:schemas:mailheader:Content-ID") = "<SecondaryHeader.jpg>"
objBP3.Fields.Update
Set objBP5 = objEmail.AddRelatedBodyPart("D:\QlikView\SGP-UDA\QVS_Source\UserApp\DailySiteDetail.jpg", "DailySiteDetail.jpg", CdoReferenceTypeName)
objBP5.Fields.Item("urn:schemas:mailheader:Content-ID") = "<DailySiteDetail.jpg>"
objBP5.Fields.Update
Set objBP6 = objEmail.AddRelatedBodyPart("D:\QlikView\SGP-UDA\QVS_Source\UserApp\SecondaryHeader2.jpg", "SecondaryHeader2.jpg", CdoReferenceTypeName)
objBP6.Fields.Item("urn:schemas:mailheader:Content-ID") = "<SecondaryHeader2.jpg>"
objBP6.Fields.Update
Set objBP8 = objEmail.AddRelatedBodyPart("D:\QlikView\SGP-UDA\QVS_Source\UserApp\WeeklySiteDetail.jpg", "WeeklySiteDetail.jpg", CdoReferenceTypeName)
objBP8.Fields.Item("urn:schemas:mailheader:Content-ID") = "<WeeklySiteDetail.jpg>"
objBP8.Fields.Update
Set objBP9 = objEmail.AddRelatedBodyPart("D:\QlikView\SGP-UDA\QVS_Source\UserApp\SecondaryHeader3.jpg", "SecondaryHeader3.jpg", CdoReferenceTypeName)
objBP9.Fields.Item("urn:schemas:mailheader:Content-ID") = "<SecondaryHeader3.jpg>"
objBP9.Fields.Update
Set objBP10 = objEmail.AddRelatedBodyPart("D:\QlikView\SGP-UDA\QVS_Source\UserApp\WeeklySiteDetailLW.jpg", "WeeklySiteDetailLW.jpg", CdoReferenceTypeName)
objBP10.Fields.Item("urn:schemas:mailheader:Content-ID") = "<WeeklySiteDetailLW.jpg>"
objBP10.Fields.Update
Set objBPDoc = objEmail.AddRelatedBodyPart("D:\QlikView\SGP-UDA\QVS_Source\UserApp\Qlikview Printing.pdf", "Qlikview Printing.pdf", CdoReferenceTypeName)
objBPDoc.Fields.Item("urn:schemas:mailheader:Content-ID") = "<Qlikview Printing.pdf>"
objBPDoc.Fields.Update
objEmail.HTMLBody = HTML
msgbox("attached objects")
objEmail.Send
Set objFlds = Nothing
Set objConf = Nothing
Set objEmail = Nothing
ActiveDocument.Save
Application.Quit
End Sub
I cannot ask questions so I will try to give you an answer of the bat.
Firstly, does it reload manually from the QV Document? If yes then
Then you are most probably using 2 differant usernames to reload, please make sure that the username used to reload via scheduler has permissions on every single file the VB is accessing.
Did you set the permissions on the VB side to the following:
Requested Module Security = System Access
Current Local Security = Allow system access
Lastly, On the General screen of the scheduled task, under security options at the bottom. Make sure "Run with highest privileges" is unticked, this sometimes causes issues.

Facebook chat reports "not-authorized", although "xmpp_login" is granted

I am trying to integrate the facebook chat into our mobile Flash/AIR application, and am using XIFF for the XMPP stuff. Of course, I had to modify some files for the newer Facebook API that uses access_token instead of sig and secret.
For those familiar with the xiff/smack API, here is how I establish the connection:
XFacebookPlatform.setFacebookSessionValues(AppData.FACEBOOK_APP_ID, AppData.getInstance().getFBSession().accessToken);
XMPPConnection.registerSASLMechanism("X-FACEBOOK-PLATFORM", XFacebookPlatform);
var con :XMPPConnection = new XMPPConnection();
con.server = "chat.facebook.com";
con.useAnonymousLogin = true;
con.connect(XMPPConnection.STREAM_TYPE_STANDARD);
.
Basically, I get to the point where I answer the challenge with what IMO should be a correct format:
var responseMap:Dictionary = new Dictionary();
responseMap.api_key = fb_api_key;
responseMap.call_id = 0;
responseMap.method = incomingChallengeMap.method;
responseMap.nonce = incomingChallengeMap.nonce;
responseMap.access_token = user_access_token;
responseMap.v = "1.0";
var challengeResponse:String = "api_key=" + responseMap.api_key;
challengeResponse += "&call_id=" + responseMap.call_id;
challengeResponse += "&method=" + responseMap.method;
challengeResponse += "&nonce=" + responseMap.nonce;
challengeResponse += "&access_token=" + responseMap.access_token;
challengeResponse += "&v=" + responseMap.v;
challengeResponse = Base64.encode( challengeResponse );
.
The response is sent, but as an answer I receive the following:
<failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
<not-authorized xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/>
This sounds like I did not grant the "xmpp_login", but I did. I checked that via the Graph API explorer, and for the same access_token it shows:
{
"data": [
{
"installed": 1,
"xmpp_login": 1,
"user_online_presence": 1,
"friends_online_presence": 1
}
]
}
This should be more than enough, I guess.
But still I get the "not-authorized" failure.
Any ideas what went wrong here?
Funny enough, the problem was this line:
var con :XMPPConnection = new XMPPConnection();
Which has to be replaced with this line:
var con :XMPPTLSConnection = new XMPPTLSConnection();
That's it. The facebook chat only authenticates with a TLS connection.
.
While that does make sense, the error message of
<failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
<not-authorized xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/>
is very misleading here, as it implies that something with the rights would be wrong.