Hello i have app written in flutter which uses data from parse server.
According to flutter doc:
/// Reset password
response = await user.requestPasswordReset();
if (response.success) {
user = response.result;
}
I'd like to send e-mail using my parser with change password link.
When i press button with that function assigned - i get information: "E-mail sent"
On flutter side i'm getting that output:
Function: ParseApiRQ.requestPasswordReset
I/flutter (28247): Status Code: 200
I/flutter (28247): Payload: {"className":"_User","email":"testazaz#gmail.com"}
On parser side i have installed something like this:
simple-parse-smtp-adapter Configured as doc says.
I don't getting any Error/Info logs from parser. Can you tell me how to configure it properly? Maybe you know other way - how to connect flutter with parser to send e-mail verification or password change e-mails.
After couple days i finally resolved this problem with help of #DaviMacêdo.
I implemented Sendgrid Adapter.
In your parse node-modules folder install this module using cmd:
npm i parse-server-sendgrid-adapter
Remember to require module at the top of the file:
var SimpleSendGridAdapter = require('parse-server-sendgrid-adapter');
var api = new ParseServer({
...,
emailAdapter: SimpleSendGridAdapter({
apiKey: 'sendgridApiKey',
fromAddress: 'fromEmailAddress',
})
});
You can get api key here
and set up sender e-mail here
I hope it helps saving much time for others facing the same problem!
Related
Hope someone can assist. Been struggling now for about 2 weeks to get the fcm push notification working on flutter web app. Using flutter 3.0.7.
I created a firebase project and set it up with cli and recieved a firebase_options.dart file with the web options. Then created a firebase-messaging-sw.js file.
When testing from firebase console I recieve a message. But as soon as I use the rest api to send a message it shows it send the message but no message is recieved. It show the following
FCM request for web sent!
{"multicast_id":3383324657233668851,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"InvalidRegistration"}
]}
FCM request for web sent!
{"multicast_id":5796359055236685312,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"InvalidRegistration"}
]}
I use the following to send the message after getting the registered key of the device I would like to send to
sendPushMessageToWeb(String? token) async {
final endpoint = "https://fcm.googleapis.com/fcm/send";
final header = {
'Authorization': 'key=7rZmxGEjVqGk0JPi0Fospb0Us47eIn8IqIDeobU8KGFbMoAYTZ-',
'Content-Type': 'application/json'
};
http.post(
Uri.parse(endpoint),
headers: header,
body: jsonEncode({
"to": "${token}",
"notification": {"body": "YOUR NOTIFICATION BODY TEXT", "title": "YOUR NOTIFICATION TITLE TEXT", "sound": "default"}
})
)
print('FCM request for web sent!');
}
It looks like it complains about the registration key but using that same key in console works.
Why would it send and recieve message from console but not from rest api? I did not made any changes in my index.html file for the code lab I used at first and is unable to find again after all my searches did not mension anything about the changes and the console messages is recieved.
Thank you
My own mistake for not thinking. I never checked the length of the token. The variable on my php mysql was only 100 long but the token is longer than that. Thank you.
How can I send for example SMS code verification in Flutter (without Firebase Auth because I have MySQL database with PHP connection).
I have tried :
Future<void> _sendCode(String phoneNumber) async
{
phoneNumber = "XX XX XX XX XX";
String code = _createCode();
String message = "The code is $code";
String uri = 'sms:$phoneNumber?body=$message';
await launchUrlString(uri);
}
And many other things, but it open messaging on my device. I want the code to be sent automatically.
I have tried to find out how to send a message from PHP but without satisfactory result.
You can try flutter_otp package I think it's the best option,
You can visit https://pub.dev/packages/flutter_otp for more info,
You can also use url_launcher package.
I'm trying to post to a Teams channel via the email address using SendGrid. However, the emails I send via SendGrid are not appearing. I ended up adding my personal email address as well, and I do receive that one as well as seeing the Teams email address in the To: field. I can also see in SendGrid dashboard that the email was send and delivered to the Teams channel address. I have validated that this address is correct, and have also posted via my non-work email address to that channel, so I know it's not because of a typo or an external email address. My guess is that there is something in the email meta data that is making Teams reject the email? Anyone have ideas 1) why Teams won't post the email coming from SendGrid and 2) how I might modify my request in SendGrid so that it works? Also, alternative suggestions on sending emails (for free) from nodejs are welcome.
Here is the code I'm using to send the email for reference:
var msg = {
to: ['TEAMSCHANNELID#amer.teams.ms','mycompanyemail#company.com'], // ChatBot Support Team, General Channel
from: 'noreply#chatbotapimonitor.com',
subject: `Service Interruption Notice: API ${test} is down (via ${functionName})`,
text: `API ${test} failed with error ${error}`,
html: `API ${test} failed with error ${error}`
};
try {
await sgMail.send(msg);
} catch (err) {
context.log(err);
}
It turns out that Teams won't accept incoming emails if the From address domain does not match the actual "sent from" domain. I recognized this by the "Sent via sendgrid.net" message I saw in Outlook when the emails were sent to me as well.
I was able to get the out of the box Incoming Webhooks enabled, and using that instead of SendGrid emails got around the problem. I got the URL from the webhook configuration and then was able to call it like so:
var headers = { 'ContentType': 'application/json'}
var body = {
'#context': 'https://schema.org/extensions',
'#type': 'MessageCard',
'themeColor': 'FF0000',
'title':`API ${test} is down: Service Interruption Notice`,
'text': `API ${test} failed with error ${error}.\n\r\n\rReported by ${functionName} during test started on ${now.toString()}`
};
var res = await request({
url: url,
method: 'POST',
headers: headers,
json: body,
rejectUnauthorized: false
});
The themeColor doesn't appear in all channels, but I have it working as a nice red/green indicator on Teams desktop.
Perhaps your organization limits the sending ability to only certain domains? Someone with admin rights can check it under Teams settings => Email integration
yeah that's what I meant - making your own Connector app and side-loading. If you go ahead with it, please let me know - would love to know how it works out
Yes exactly making your own Connector would work.
I want to use Google Tag Manager to send data to our Salesforce org for certain events on our website (user signup, conversion etc). After some research, I realized JSforce would be the easiest way to achieve this. I created a new connected app in Salesforce, tried out the Salesforce API using Postman and successfully managed to create a new user account via the API. Then I moved on to try and achieve the same thing in Google Tag Manager. I read JSforce's docs and attempted to implement everything. But, after multiple hours of troubleshooting and Google searching, I can't seem to make it work.
Here is my current code, which is in a 'tag' in Google Tag Manager that triggers on all pages (just for testing):
https://jsforce.github.io/start/#web-browser
<script src="//cdnjs.cloudflare.com/ajax/libs/jsforce/1.9.1/jsforce.min.js"></script>
<script>
jsforce.browser.init({
clientId: '<MYCLIENTID>',
redirectUri: 'https://cuttersclub.com'
});
https://jsforce.github.io/document/#access-token
var jsforce = require('jsforce');
var conn = new jsforce.Connection({
instanceUrl : 'https://um5.salesforce.com',
accessToken : '<MYACCESSTOKEN>',
});
https://jsforce.github.io/document/#create
conn.sobject("Account").create({ Name : 'My Account #1' }, function(err, ret) {
if (err || !ret.success) { return console.error(err, ret); }
console.log("Created record id : " + ret.id);
});
</script>
I'm getting this error in the browser console:
Uncaught ReferenceError: require is not defined
EDIT: Removing var jsforce = require('jsforce'); solved this problem and accounts are being created in Salesforce. But, now I am getting the following error in the browser console:
Access to XMLHttpRequest at '<URL>' from origin '<CALLBACKURL>' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
As mentioned in the JSforce docs, I think it may be something to do with proxy servers: https://github.com/jsforce/jsforce-ajax-proxy
I don't know that much about salesforce, but "require" is something from node.js, not a function that is implemented in the browser.
If I understand the documentation correctly, then for a browser project it should be enough to call the jsforce script via a script tag. You should not need any way to "require" files after that, since the jsforce script already contains everything you need. So you should be fine if you just remove the offending lines (i.e. all references to "require('jsforce');").
Per the recommendation in the defaultauth sample, I am trying to access the directory api for a domain which I have created a service account for. Here is the code I am attempting to connect with:
import { google } from 'googleapis'
const authClient = await google.auth.getClient({
scopes: ['https://www.googleapis.com/auth/admin.directory.user.readonly']
})
const service = google.admin('directory_v1')
console.log(
await service.users.list({
auth: authClient,
domain: <redacted>
})
)
However, when I attempt to connect I recieve an error saying Error: Not Authorized to access this resource/api. If I remove the creds.json file in ~/.google, the error changes to saying that it cannot find the credentials file. Also, I am able to access a bucket using the same file, so I'm pretty sure my local environment is set up correctly, authentication wise. I have also worked for the past few days with someone on the support team G Suite API team, who assures me that things are set up correctly on my domain.
After looking around online, it seems the thing I am missing is impersonating an admin account when trying to connect with my service-account. I have found a few examples online of doing this with a JWT auth strategy, but I would like to continue to use the default auth client, in order to abstract away the implementation details. Is this possible? If so, what do I have to change? I have tried setting subject, and delegationEmail in both of the calls (getClient and list).
Any help would be greatly appreciated.
Just set subject of the client object:
authClient.subject = 'your email address'
Google's api documentations highly varies by language. No standart. Something documented in PHP client may be missing in nodejs client and it can take hours to find out how to do it.
You can pass clientOptions.subject in the constructor.
import { google } = from 'googleapis';
const authClient = new google.auth.GoogleAuth({
scopes: ['https://www.googleapis.com/auth/admin.directory.user.readonly'],
clientOptions: {
subject: "your email address"
});