How to use Google Calendar's watch method inside a Chrome Extension without a server - google-chrome

In my Chrome extension is it possible to use Google Calendar's API watch method to receive push notifications instead of pollling without hosting my own server?
Can Firebase/FCM or chrome.gcm provide a solution? cloud based perhaps?

You can avoid the long polling but you'd still have to host a server even for the FCM.
I'd suggest you;
Go with Heroku, set up a free NodeJS dyno for your server. You can use the free MongoDB addon as your DB. Use the guide here to setup the server.
Setup FCM client in your extension using the guide here. Request the notification permission and get token on install or if you have a login system in your extension, after user has authorized. Send the token to your server and save in DB against that user's id or any other unique id that you can track from Calendar notification.
Use the Heroku app URL as target in Watch API. So all the notifications will be delivered to your Heroku instance.
When a notification is received from Calendar API;
Use any form of id in that notification and find the user's device/FCM token from DB.
Use that token as to and send message to that device. Handle the message on device as you want.
Calendar API -> Heroku Server -> FCM Server -> User Device
Means no need for 'long polling'. Your notifications will be delivered in realtime. Depending on the usage, you could also keep the Heroku instance free.

Related

Remote Debugging Azure App Service with API Management?

Is there a setting necessary to be enabled for APIM to forward remote debugging calls to its associated app service? When I portqry, the port is reported as Filtered, not Listening.
There is a workaround to the problem. First, download the latest publishing profile for the app service and open it. With the project loaded, select Debug > Attach to Process. Use the destinationAppUrl in the profile for the Connection target. Append the url with ":4024" and tap "Enter". That will start the connecting to the cloud debugger for the app service. A login dialog should appear. Use the
first userName and userPWD values to fill the dialog. When entering the userName, prefix it with a backslash so your local domain is not applied. Select the Attach button.
From my experience to date, multiple attempts may be necessary. When that fails, try disabling Debugging in the app service and re-enabling with saves in between. Also restarting the app service might assist.

Is there a way to connect with EWS without user credentials if I'm not using Office 365?

Original jamesiarmes/php-ews offers authentication only by username / password. Fork by Garethp has some OAuth function but it requires Office365 and registering application in Azure. Is there any possibility to connect to Outlook by web browser just relying on user logged to Windows System? I know how to read which user is logged using kerberos, but don't know if it's right tool to make it.
There's no way with either of those tools. I looked in to trying to use Network Authentication as method of Auth, since my fork uses NTLM any way, but I couldn't find any resources on passing the NTLM Authentication over SOAP calls. That being said, if you can find some examples, I'd be happy to build it in as a method of authentication for you
In the EWS service object, you can select the flag to use default credentials, meaning whatever user context the code is running under. Would that help?

How can I send a message to a Chrome extension from an App Engine server?

I would like to be able to send messages from an App Engine server to a Chrome extension. When the Chrome extension receives a message, it should increment the badge over the icon. Is it possible to send messages directly, or do I have to poll the server continuously from the extension?
You should look into the Cloud Messaging API, specifically chrome.gcm API.
This would be the best way to notify the extension from the server side, and can be a two-way communication channel.

Google Drive upload from webserver

I'm trying to make a service that runs on a webserver and can upload files to Google Drive,
so that people can sync the files to local-drive using the Google desktop application.
So I tried the Drive API but it requires a webbrowser to authenticate.
This would be a possibility, but I don't know to get the access token programmically.
Even if I had the access token, I wouldn't know if it just works forever.. It seems to have an expire date?
I wouldn't want the service to suddenly not working, because the token has expired.
Than I learned about Service Account, and finally got it working, but it seems to have its own space that i can only access with the service account.
I don't know how to share the files from the service account to a regular account, as people need to sync it locally.
So a found a video about user impersonation, in which he showed a page about given access to a service account to impersonate another user.
But i don't know where to find this page.
Looking at: http://support.google.com/a/bin/answer.py?hl=en&answer=162106&topic=2759255&ctx=topic
It says it's in Advanced Tools > Manage third party OAuth client access (under the Authentication section).
But where is the Authentication section? Do I need to create a Google App to do this?
The question is: How upload files programmically to Google Drive without any user intervention, so that they can be synced locally with the drive desktop-application.

Can I authenticate with Google username and password in Google Drive API?

Can I authenticate with just Google account username and password instead of using OAuth? If not, is it planned to support this kind of authentication in the future versions of Google Drive API?
I am currently using Google Documents List API which allows to authenticate with just username and password. So I am wondering if I can I do the same thing with Google Drive API.
Are there any reasons you cannot use OAuth 2.0 as your authorization mechanism?
Client Login is currently being deprecated and it would be better for you and your users to use OAuth 2.0.
There are multiple code samples available in the Drive SDK documentation as well as in the various client libraries project page to help you get started.
If you are running a server application, consider using a service account with OAuth2 and the Drive API. This will allow you to run the app on a server without a user having to provide OAuth2 credentials on the console or through a UI. You can also do impersonation if you want your app to act on documents with a specific account.
GoogleCredentials credentials = new GoogleCredential.Builder()
.setTransport(HTTP_TRANSPORT)
.setJsonFactory(JSON_FACTORY)
.setServiceAccountId("[[SERVICE_ACCOUNT_EMAIL]]")
.setServiceAccountScopes(DriveScopes.DRIVE, DriveScopes.DRIVE_FILE,
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/userinfo.profile")
.setServiceAccountPrivateKeyFromP12File(Auth.keyFile)
.setServiceAccountUser("[[impersonateduser#domain]]")
.build();
credentials.refreshToken();
I've found this blog post somewhere (possibly here): http://blog.databigbang.com/automated-browserless-oauth-authentication-for-twitter/.
I know it is regarding Twitter, but it uses the same method, so I reckon it just needs a little tweak in the names. In short: if the script is run only by server, install Jython + HTMLUnit, simulate user going to the generated authorization link and clicking 'allow access' button and get token.