I have registered for receiving Google Classroom push notifications from Google Cloud Pub/Sub for my Google classroom class. I have registered for one of my specific classID. I am successfully able to receive notification every time student/teacher is added/removed in the class. But the data parameter which looks like holds the actual json for the delta seems to be encrypted. Does anyone know the encryption format and how I can change it and also if I can find more documentation for it.
The json that I received on my listener end point is like this-
(I have scrambled the data)-
{"message":{"attributes":{"registrationId":"-091231239109812309"},"data":"sadfuasoufyasufwehgsgdaHDFADAbnxznbnsF[WEIUPEQUYUWSDSFDJSFHLASLSFahdgsHasdhskjsdljhsdfsaX=","messageId":"4323240932612037","message_id":"4323240932612037","publishTime":"2018-05-09T05:28:13.948Z","publish_time":"2018-05-09T05:28:13.948Z"},"subscription":"projects/thisproject/subscriptions/thissubscription"}
It is base 64 encoded. Not documented in Google documentation.
Related
I want to implement a connected OAuth app in Salesforce which should trigger push events in case some entities changed, for example an opportunity was closed.
Zapier implemented something similar
https://zapier.com/apps/salesforce/integrations/webhook
Could not find something I need which is a simple way to subscribe to entity changes using the OAuth client's token and passing a webhook endpoint. I read about apex callouts, streaming API and outbound messages.
Yeah, we solved this exact problem at Fusebit and I can help you understand the process as well.
Typically speaking here's what you need to do:
Create triggers on the Salesforce Objects you want to get updates for
Upload Apex class that will send an outgoing message to a pre-determined URL
Enable Remote Site Setting for the Domain you want to send the message to
Add in Secret Verification (or other auth method) to prevent spamming of your external URL
If you're leveraging javascript, then you can use the jsforce sdk & salesforce tooling API to push the code into the salesforce instance AFTER the Auth flow has occurred AND on Salesforce Instances that have API access enabled (typically - this is enterprise and above OR professional with API enabled).
This will be helpful for you to look through: https://jamesward.com/2014/06/30/create-webhooks-on-salesforce-com/
FYI - Zapier's webhooks implementation is actually polling every 15 minutes, instead of real-time incoming events.
In which programming language?
For consuming outbound messages you just need to be able to accept an XML message and send back "Ack" message to acknowledge receiving, otherwise SF will keep trying to resend it for 24h.
For consuming platform events / streaming API / Change Data Capture (CDC) you'll need to raise the event in SF (Platform Event you could raise from code, flow, process builder, CDC would happen automatically, you just tell it which objects it should track).
And then in client app you'd need to login to SF (SOAP or REST API), subscribe to channel (any library that supports cometd should be fine). Have you seen "EMP Connector", mentioned for example in https://trailhead.salesforce.com/en/content/learn/modules/change-data-capture/subscribe-to-events?trail_id=architect-solutions-with-the-right-api ?
Picking right messaging way is an art, there's free course that can help: https://trailhead.salesforce.com/en/content/learn/trails/architect-solutions-with-the-right-api
And pretty awesome PDF if you want to study for certification: https://resources.docs.salesforce.com/sfdc/pdf/integration_patterns_and_practices.pdf
We are working with a google my business integration.
The API documentation is pretty exhaustive, except for the notification schema used on pub/sub.
we are unable to find the correct information.
Does anybody know what the data looks like?
API docs
For the new Notifications API, you have the following basic pattern:
{
"review":"accounts/*/locations/*/reviews/*",
"location":"accounts/*/locations/*",
"type":"NEW_REVIEW"
}
Q&A messaging is broken (more see Google My Business push notification is not sent for Question and Answers ).
For GoogleUpdate messages, you will just get the type and location properties.
I was able to set up Google Cloud Storage Cloud Pub/Sub notifications using:
gsutil notification create -t [TOPIC_NAME] -m my-key:my-value -f json gs://[BUCKET_NAME]
My App Engine servlet correctly gets a message every time an object is uploaded to GCS. I upload my object to GCS with a Signed URL.
However, I'm not sure how to set custom key-value pairs from my client when uploading an object with the Signed URL. The above gsutil command lets you set a key:value pair but it hard-codes it so that is not useful. In my client I want to set some key:value pair like user : some-user so then in my servlet I can do some extra App Engine stuff like write to a database.
I tried uploading some headers in the metadata tag as shown here but getting those headers from the HttpServletRequest in the servlet didn't seem to work.
Also, how would I sent the subscriptionUniqueToken as well, since there is no explanation on how to do that.
Note: using Java
The notion of a unique token is no longer necessary in most cases. Object change notifications offered them because they worked by sending unauthenticated HTTPS calls to a configurable endpoint. If that endpoint were discovered, a malicious user could also send such calls. However, Cloud Pub/Sub notifications publish messages to a topic as a known service account, and so long as no malicious third party is also granted publishing permission to that topic, they cannot interfere. If you want, you can include a unique token as a second protection mechanism, but it's generally not necessary.
"Client tokens" are a feature specific to Object Change Notifications. The equivalent with Cloud Pub/Sub integration are "custom_attributes", user-specified properties of a notification config that are attached as extra attributes to each notification. You could add a "unique_token" attribute and attach a value, if you wish.
When using signed URLs, setting custom metadata is done with HTTP headers beginning x-goog-meta-. For example, x-goog-meta-stuff: Foo will create a custom attribute pair "stuff: Foo".
I made a pass web service already. Next, I need to make a push notification when my pass is updated. From Updating a pass of passkit programming guide, it is not in detail. Can you explain this in detail ?
The requirements and protocol for push notifications is documented in the Push Notification Programming Guide.
There are a few special considerations for Passbook:
All Pass push requests must be sent to the production APNS server (gateway.push.apple.com on port 2195)
You must use your Pass Type ID certificate and key to authenticate with the APNS server (do not use App APNS certificates)
There is no need to handle device registrations, you simply use the pushToken that your web service received when the device registered the pass
The payload should be an empty - E.g. {"aps":""}
alert, badge, sound and custom property keys are all ignored - the push's only purpose is to notify Passbook that your web service has a fresh pass. The notification text will be determined by the changeMessage key in pass.json and the differences between the old and the new .pkpass bundles
ThechangeMessage string should contain %# if you wish for the content of the value key to be displayed. Change messages may have static text in addition to the %# variable, such as this: "changeMessage":"New updates: %#". If no %# is provided, a generic message with the kind of pass is displayed: "Store card changed".
As of iOS9, if you modify more than one field at a time, only one generic message will be displayed on the lock screen.
You still need to regularly query the feedback service and purge expired/invalid pushTokens from your database
Note that push updates can be implemented independently of your web service. Apple provide some sample objective-c code in Listing 5-1 here.
i want to know how to get the original sender of a forewarded mail using google app engine
mail_message.original object?
From the docs : If you use Python you have to analyze the message :
original is the complete message, including data not exposed by the other fields such as email headers, as a Python email.message.Message.
http://docs.python.org/2/library/email.message.html