How does a service identify the user? - google-mirror-api

Use case:
A user takes a beautiful photo and wants to save it to their evernote account.
User authorizes with OAuth 2.0. The service stores their credentials.
Just after the OAuth 2.0 dance completes, the service inserts a contact called "Save to Evernote".
Next, the service subscribes to updates in this user's timeline by inserting a subscription for the timeline collection.
The user activates the contact. Save to Evernote is now fully set up.
Over time, the user takes photos.
The user shares a photo with Save to Evernote. This makes the timeline card associated with this photo accessible to the service.
Because the service is subscribed to timeline updates, a notification is sent to your service. This notification links to the timeline item containing the shared photo.
The service examines the notification and uses the included id to fetch the timeline card that contains the photo.
Next, the service examines the timeline item and uses the attachment ID to fetch the bytes of the photo.
The service uploads the photo to the user's Evernote.
Finally, the service constructs a new timeline card and inserts it into the user's timeline card with the success message.
From the Mirror API Documentation it appears that once a user shares a timeline item the service receives a POST quite like this:
{
"collection": "timeline",
"itemId": "3hidvm0xez6r8_dacdb3103b8b604_h8rpllg",
"operation": "UPDATE",
"userToken": "harold_penguin",
"verifyToken": "random_hash_to_verify_referer",
"userActions": [
{
"type": "SHARE"
}
]
}
Is the userToken a value that I receive when first authenticating the application? If so can I use that value to connect the POST received from Glass with the User saved in my database? If not how do I connect the share to my service's contact with the Glass user so that my service can perform services specific to that user on their behalf?

The userToken is indeed the field you use to correlate the notification back to the user who triggered it.
You set the userToken when you create a subscription for that user. Whatever value you specify when you insert the subscription is provided as the userToken for all of the notifications that it yields. This means that when you create subscriptions, you always want to use unique identifiers that your system can correlate back to the correct user.
For example:
Jane authenticates with your service. Jane has the unique user ID of 42 in your Glassware's database.
At the time of authentication, you subscribe to her timeline collection by inserting this subscription:
{
"collection": "timeline"
"userToken": "42",
"callbackUrl": "https://example.com/notify/callback"
}
Jane shares a photo with your Glassware.
A notification is sent to your service. It looks something like this:
{
"collection": "timeline",
"itemId": "3hidvm0xez6r8_dacdb3103b8b604_h8rpllg",
"operation": "UPDATE",
"userToken": "42",
"userActions": [
{
"type": "SHARE"
}
]
}
Your Glassware uses the userToken property to look up the correct user: Jane.
The rest of the story proceeds as you describe in your question.

Related

azure logic app not able to retrieve who is the approver after approving the mail(UserEmailAddress- showing Null)

I have created a flow using logic apps where once the owner approves the mail I need to know who approved that mail. While using normal my account I am able to retrieve the user who approved the mail but while using the service account am not able to retrieve the values. All the values its showing as null while using the service account.
How do I get the --> email address <-- of the user that selects 'Approve' or 'Reject' buttons in the email? If an email is forwarded to another person I would like to know who (email address) clicked approve or reject.
After reproducing from my end, I observed that when the mail is viewed in HTML format this doesn't work and also while forwarding the mail, but this works when the response is sent through the adaptive cards and not the HTML message that are received during the Send email with options action. One way that this can work is when you use only the adaptive cards that are send as the request.
RESULTS:
and when you use HTML responses then below is something how you'll be receiving the response.
You can also try Creating your own actionable messages for Flow Approvals by StefanS365 where in you add provider in Actionable Email Developer Dashboard and request the approvals.

MS Graph API frequently/excessively triggering the client app against Active Directory User changes

Background:
I wanted to receive notifications in a Logic App for Azure Active Directory Users' changes. I created a subscription to AD User changes using Microsoft Graph's REST API:
POST https://graph.microsoft.com/v1.0/subscriptions
{
"changeType": "updated",
"notificationUrl": "https://mylogicapp.com",
"resource": "/users",
"expirationDateTime": "2021-11-11T11:00:00.0000000Z",
"clientState": "SecretClientState"
}
I received 201 Created HTTP response code and began receiving the notifications in the application. (See Microsoft Docs).
Issue:
I am receiving a lot more than the expected notifications, very frequently. I just want to receive notifications scoped to AD User resource type and not any child resource type. What could be the issue behind that abundant User changes' notifications? Did I do anything wrong or missed anything while setting the scope in Subscription Creation request?

Pull data fro API using Azure Logic Apps

I need to Pull data from a 3rd party API and minor process that data and then send it to DB. Is there any connector to pull API data using Logic App? Any connector or Action? How to start.
It seems you wants to fetch data from any API using logic App right?
Yes you can do it using Logic Apps Custom Connector on azure portal see the screen shot below:
How to connect any API with Custom Connector:
Step 1: Create New Custom Connector
To create a Custom Connector go to azure portal and in All services search for Logic Apps Custom Connector click on it and Add New Connector. see the screen shot:
Step 2: Edit Custom Connector
Once you have created new custom connector then to add your API with it you have to Edit it to configure your API request and response with the new custom connector
Step 3: Configure Custom Connector
There are 3 part of custom Connector
1. General
Here you would see Host enter your API main domain name like dotnetavalanche.azurewebsites.net
Leave base URL blank
2. Security
For test propose no authentication required just leave it blank
3. Definition
enter a Summary note , description but surely enter a Operation ID which should unique like TestAPI
Request
Then in Request selection click on Import from sample and enter your API method type Like POST or GET
Full URL of your API for example: https://dotnetavalanche.azurewebsites.net/api/PartnerBotRequest
See the screen shot:
Response:
Here click on Add default response and add Json of your expected response from API
Call Your custom Connector On Azure Logic App
Go to azure logic App and click on Http Request on Request Body JSON Schema paste below JSON
{
"type": "object",
"properties": {
"title": {
"type": "string"
},
"description": {
"type": "string"
},
"email": {
"type": "string"
}
}
}
Then click on Next Step and add your custom connector like below:
Then finally add new Step as Response
Configure the response as below screen shot:
If you still have any query feel free to share. Thanks and happy coding!

Firebase AngularJS full data access

I'm building an app based on Firebase + AngularJS. I'm using User management service by Firebase. I'm able to get all data for Authenticated user, however, I'm not able to retrieve all user data as admin. How can I get full access to Firebase data.
Thanks!
As Frank mentioned in the comment, Firebase doesn't make user account information available to the admin. Rather, some information is available on the client after authentication and it could be sent to be stored as explicit data in Firebase.
The link Frank provide in the comment explains how to do this.
Applications do not automatically store profile or user state. To persist user data you must save it to your database. The callback function will return an object containing the data for the authenticated user, which you can then write to your database.
Here is the core of the example
var ref = new Firebase("https://<YOUR-FIREBASE-APP>.firebaseio.com");
ref.onAuth(function(authData) {
if (authData && isNewUser) {
// save the user's profile into the database so we can list users,
// use them in Security and Firebase Rules, and show profiles
ref.child("users").child(authData.uid).set({
provider: authData.provider,
name: getName(authData)
});
}
});

Retrieve a logged in Google Glass User's email address?

We are attempting to be able to provide the ability for a Glass user to request an email to be sent to them from a Timeline Card. On the notify callback Servlet, we are attempting the following to retrieve a user's email address:
String userId = notification.getUserToken();
Credential credential = AuthUtil.getCredential(userId);
Mirror mirrorClient = MirrorClient.getMirror(credential);
Contact contact = MirrorClient.getContact(credential, userId);
We do not get a result back when retrieving an email off of the UserInfo object of a authenticated user. Our application has the following scopes available to the application server:
"https://www.googleapis.com/auth/glass.timeline "
"https://www.googleapis.com/auth/glass.location "
"https://www.googleapis.com/auth/userinfo.profile "
"https://www.googleapis.com/auth/userinfo.email "
"https://www.googleapis.com/auth/contacts"
Are we allowed to retrieve the authenticated user's email address, is there a permission I am missing or is there another means by which to request that data?
The getContact call you are making doesn't have anything to do with the user's email address. You can read up on what Contact is referring to here:
https://developers.google.com/glass/contacts
To get the user's email address, I've successfully used the same auth token used to authorize the Glass mirror API app with the added scope you mention to call this URL:
https://www.googleapis.com/userinfo/email?alt=json
This method seems to stop working after the initial authorization at some point, so be sure to do it when the user first authorizes the app and save off the email.
Although I've also just gotten the email off AppEngine's UserService before as well, which is easier if you happen to be running on AppEngine:
https://developers.google.com/appengine/docs/java/javadoc/com/google/appengine/api/users/UserService
So the question boils down to "Why am I not getting contact info for this userID that I am sending to the Google Mirror service?"
The Mirror service only provides contact information for Contacts that your Glassware has added. See https://developers.google.com/glass/contacts for more about Contacts in Glass and how to add Contacts. Unless you have already added a Mirror Contact with this userId, you won't get anything back.
The Mirror service does not provide direct access to the information from userinfo.info or userinfo.email. You will need to get it out using the OAuth2 libraries first if you want to add them as a Contact for Glass.

Resources