How to get gcm_sender_id for website in Firebase - javascript

I am trying to use push notification for my web site..
I am trying fcm. In the Google documentation (https://firebase.google.com/docs/cloud-messaging/js/client) they told us to use gcm_sender_id in manifest.json file, but I don't find it any where in firebase page https://console.firebase.google.com/project/fir-98798789/overview
Also they have mentioned
Don't confuse the "browser sender ID" with the project-specific sender ID value shown in your Firebase project settings. The browser sender ID for manifest.json is a fixed value, common among all FCM JavaScript clients.

The sender ID that you enter in the manifest.json of your web app is independent of your Firebase project. It is the same for all web apps (yours, mine, everybody's):
"gcm_sender_id": "103953800507"
So just copy/paste the line above into the manifest.json for your project. See this section of the FCM documentation.

Seems like Firebase Messaging actually works even if you skip this step. Look at https://web-push-demo-11213.firebaseapp.com as an example.
This demo website doesn't even have a manifest but is able to talk to FCM, get tokens, refresh them and so on.. Sorry you won't be able to actually send a push though since you don't know the auth key, but you get the idea - I've tested it, it works.
In light of this, not sure why this manifest requirement though.
Also, looking at the FCM SDK source on github, looks like they only throw an error if you have a manifest with a gcm_sender_id that's not 103953800507. For everything else (the gcm_sender_id field in manifest missing, or even the manifest itself missing from the website), it works as fine.
See the code here: https://github.com/firebase/firebase-js-sdk/blob/master/packages/messaging/src/controllers/window-controller.ts#L329-L355

Goto https://console.firebase.google.com -> select your project.
Settings -> Cloud Messaging -> Project credentials -> Sender ID
Hope this help!

Related

How can I get attachment content from an Outlook mail in a Node.js Outlook add-in?

First of all, being a student, I lack some experience to understand everything about what I tried and what I try. But still, I feel like I've tried pretty much every solution available on the net.
I'm developing a Yeoman based Outlook add-in (full javascript with Node.js) for my company, and I came to the point where I need to get the attachments from a mail, not just the informations like size, file type or name of the attachments, I need the full content, in base64 if possible (in order to produce a .eml file containing the mail body and attached files).
I've found multiple ways to do so, problem is none of them work :
first I tried with the messy microsoft documentation, and the first solution that I found is this one : https://learn.microsoft.com/en-us/office/dev/add-ins/outlook/get-attachments-of-an-outlook-item, problem is that with this solution I need to make use of c#, but my add-in is full js, and I need to find a solution that works with JS and Node.js
then I looked for a solution that allows me to communicate a way or another with the Exchange Server to get the attachments content, and I found this : https://github.com/gautamsi/ews-javascript-api, but this was not working with browser oriented add-in (and I need my add-in to work on both client and browsers), so I made use of this : https://github.com/gautamsi/ews-js-api-browser. I found some code samples in the first link and here : Save outlook Email attachment using ews-javascript-api npm in node JS that helped me build something (using the second link's example's syntax on the third link's sample code) that was supposed to work, but coming to the point where I'm trying to get the attachments from the mail, I get a lot of informations from the attachment, but anything related to it's content is null, and the next step where I "Load" the file returns an error 500 from the "service" with "the document is empty", and I still don't know why yet.
finally, I tried to take a step back, looking on google for office api and how to get attachment content, and I've found this link : https://blog.mastykarz.nl/office-365-unified-api-mail/ that almost looked to good to be true, and I was right : according to microsoft doc, I need a token in order to make work the office 365 api url, token given by Azure AD when an administrator authorizes you to obtain it (or so do I think, this is the part where the microsoft doc is the messier). Problem is, while connecting on Azure AD, I get an error displaying on the screen from the website (absolutely no details about the error), and some places that I need to access in order to get my token just wont work, displaying another error message without any details or just never loading.
I've reduced as much as possible the size of my question, not wanting to drown you under informations, sample codes, links and pics so, sorry if it may look both too long and too poor in details.
Thank you for your time, feel free to give any solution, suggestion or advice that come to your mind !
doing the same thing, solution I found:
Get exchangeToken in client (Office.context.mailbox.getCallbackTokenAsync())
Send token, attachmentsIds, emailID to server (C# in my case, nodejs in your case)
Use EWS Managed API 2.0 or in your case ews-javascript-api to handle loading email mimecontent (contains email + attachments) or attachment mimecontent.
Upload file to another service or do whatever you want with it.
Before I switched to C# for serverside I was using a nodejs one for testing, so if you have questions feel free to ask.

Invalid Developer's Key in Google Drive API

Im researching about some custom google API and in the site it seems to be running okay. im able to upload the desired file to my own drive account, but when i tried it to my local environment its not working. i already changed the developer's key. the oauth seems to be okay but the developer's key might have a problem. here is the demo that the guy provided. https://howdy39.github.io/google-picker-api-demo/ but when i tried it to my local environment its not working, any of them. here is a sample picture of the problem This happens after the login screen so the auth keys are okay. i dont know what to do with the developer's key. here is the original source code provided. https://github.com/howdy39/google-picker-api-demo/blob/master/docs/index.html
Please check Credentials - API key - Accept requests from these HTTP referrers (web sites).
Try adding localhost.

Grabbing data necessary for Oauth2 google using chrome extenion identity.

My question is how to grab the the correct information from the developers console and than apply that to my chrome extension. So far i understand that permission "Identity" need to be included within the manifest. Also that oauth2 with client_id and scopes also need to be added.
https://developer.chrome.com/extensions/app_identity#update_manifest
The website itself explain to grab the client id within the old versions of the website.
Information that i need to acquire from developers website:
API_Key
Scopes
Key
If possible i would liked further advice concerning the js to be able to grab the usernames first and last name and other ability such as google drive document creation or edits.
I've found a wizard on google api site
https://developers.google.com/drive/v3/web/quickstart/js
That gives me all the information i need <3

How do I use the Syncano Javascript user API?

I can't figure out how to use the Syncano Javascript user API in a node.js web app to log in a user, nor to create a new user, nor to fetch the user given the user auth token.
Is there sample code showing this anywhere, or more comprehensive docs? Thanks.
If you perform npm run build, there will be a new sub-folder called docs. Open up index.html and you will have a full lib overview.
Also, the HTTP API Reference will have a JavaScript tag for most code examples. You will want to find the sections for Users and User.
Hope this helps!

Can't POST FormData to a Google Sheet, would like to restrict access to people invited to edit the spreadsheet

I have a simple page with a form, and I decided to offer the option of submitting it to a Google Sheet. It's meant as part of an internal webapp, used by a few collaborators to submit to a spreadsheet shared between us. I would have used a Google Forms but I wanted more control over the form.
I have set up a Google Apps Script bound to the spreadsheet following these instructions and deployed it as web app with:
Execute the app as: Me
Who has access to the app: Anyone, even anonymous
This works fine, I can POST FormData with XMLHttpRequest (vanilla javascript). But so can anyone else, no matter if they're allowed to edit the spreadsheet, even if they're logged out of Google.
I'd like to restrict access to the web app - only people invited to the spreadsheet should be able to use the web app to insert rows. (Which is what I expected in the first place... if you don't have edit permissions you don't get to edit, period.)
At the moment switching the Google Apps Script Deploy as web app settings to anything else results in an 'Access-Control-Allow-Origin' error. I probably have to do something else - either in my page or in the GAS - to handle auth, right?
I want the web app to be deployed as
Execute the app as: User accessing the app
Who has access to the app: Anyone
and when a spreadsheet collaborator visits my page, he can submit the form - provided he's logged into Google.
the google apps script execution api does what you need. its well explained in the official docs:
https://developers.google.com/apps-script/guides/rest/api
its too broad to explain here step by step. you might need to read also about how to make an oauth2 flow from browser javascript.

Categories