Track Microsoft Teams userid for who opened the tab (created by bot) - rest

I have a Microsoft teams bot that creates tab in channel on certain requests.
I want to track who is the user in channel who opens the tab.
Is there a way to do so?
Any help is appreciated. TIA!

You can try to Get Context for your Tab. It return the User Object ID, Login Hint, User Principle Name of the user who is accessing the Tab
Here is the Method which you can call:
You can also retrieve the information listed above using the Microsoft Teams JavaScript client SDK by calling
microsoftTeams.getContext(function(context) { /* ... */ }).

Related

Embed google apps in Microsoft Teams Tab getting error called "refuse to connect"

I have built an MS Teams application for the goggle classroom. When I embed that application in the MS Teams tab, I was able to get a login popup for login credentials. And then I was able to get the auth token from google for my account. And When I try to redirect to the google classroom page by creating a tab URL with the help MS Teams SDK javascript, it doesn't work.
function setGoogleClassRoom() {
// This API tells Microsoft Teams to enable the 'Save' button. Since Microsoft Teams always assumes
// an initial invalid state, without this call the 'Save' button will never be enabled.
microsoftTeams.settings.setValidityState(true);
microsoftTeams.settings.registerOnSaveHandler(function (saveEvent) {
// Let the Microsoft Teams platform know what you want to load based on
// what the user configured on this page
microsoftTeams.settings.setSettings({
contentUrl: createTabUrl(), // Mandatory parameter
entityId: createTabUrl(), // Mandatory parameter
suggestedDisplayName: "Google Classroom",
websiteUrl: "https://classroom.google.com"
});
saveEvent.notifySuccess();
});
};
function createTabUrl() {
return `https://classroom.google.com`;
}
Any help would be appreciated.
Error Screenshot:

Exclude permissions from Facebook API

Apparently when calling FB.login, the default permissions the user will have to give is this:
"xxx will receive the following info: your public profile and friend list".
And I know that I can add extra permissions with: { scope : 'email' } and so on.
The problem is, I don't want the whole public profile and the friend list.
The only thing I want is: first name, last name and email.
Is it possible to exclude the basic permissions and just have the ones I want?
No, not possible.
https://developers.facebook.com/docs/facebook-login/permissions/:
“When someone connects with an app using Facebook Login, the app can access their public profile and friend list, the pieces of information that are visible to everyone. ”

How to redirect the user to a custom page when user click "Connect to QuickBooks" button?

So Intuit charges for each active connections to QuickBooks. Therefore, I want to restrict the QuickBooks functionality in my application to premium users only.
Ideally when any user clicks the "Connect to QuickBooks" button and my RequestOAuthToken http handler is called, I want to check if the user is allowed to use QuickBooks. If that is the case, then the normal OAuth flow continue. If the user is NOT allowed, then I want to redirect the user to the upgrade page of my app.
Given that the "Connect to QuickBooks" button opens a new window (at least on desktop, I haven't tried on phone/tablets), the window should get closed, and the main window (my app) should redirect the user to the right page. And actually this is exactly what happens if the normal OAuth flow completes.
Now, I have tried a few different approaches but I couldn't get it working.
1) In my RequestOAuthToken, return a HTTP redirect to the plan page
2) In my RequestOAuthToken, return an html page with javascript logic to redirect to page
3) In my RequestOAuthToken, return HTTP redirect to a page with javascript logic to redirect to page
4) I haven't tried that one but could I somehow intercept the javascript click handler on the Intuit button. I'm not sure if that is an accepted practice.
Here is the piece a javascript I grabbed from the .Net sample:
try
{
var parentlocation = window.parent.opener.location.hostname;
var currentlocation = window.location.hostname;
if (parentlocation != currentlocation)
{
window.location = plansUrl;
}
else
{
window.opener.location.href = window.opener.location.href;
window.close();
}
}
catch (e)
{
window.location = plansUrl;
}
Help me out please.
I don't think you'll be able to do exactly what you're asking, but you can probably come close by taking a different approach.
Rather than trying to redirect them after they click the button, why not try to redirect them before they click it? e.g. when they try to get to the page that has the "Connect to QuickBooks" button it, check if they are a premium user there, and redirect them if they are not.
I don't think you'll be able to redirect them after they click the button because once they click that button, they get kicked over to Intuit's website and it's beyond your control at that point.
Clement, Keith has provided the answer we would want you to pursue. You may not alter the behavior of the Connect To QuickBooks button. It must be used as described in our documentation. Providing a link to a page that shows the Connect To QuickBooks buttons for your premium users and an upgrade message to non-premium users is the way to go.
I highly recommend that you visit http://docs.developer.intuit.com/0025_Intuit_Anywhere/0010_Getting_Started/0040_Publishing_Your_App and review all of the documentation there. If you develop with our guidelines and requirements in mind it will speed up the review process.
Tony Purmal
Developer Relations Engineer
Intuit Partner Platform

Facebook Graph API - Events ticket_uri

I am trying to add a ticket_uri to the event that I am creating.
I enabled the "Events Timezone" migration in my app settings.
I am posting on behalf of a user that is manager of the page.
Currently it's not working when I create a new event. The new event has no ticket uri.
If I update the new event, just after it's created, the ticket uri works...
Is this a bug or am I doing something wrong?
$fbEvent = $facebook->publish('/events', $event);
if(isset($fbEvent['id']))
{
$facebook->publish('/' . $fbEvent['id'], array('ticket_uri' => 'http://lowiebenoot.be'));
}
Updating right after it's created is just stupid...
You must get a "Page access token" and then post to {page_id}/events. Here's a copy of the steps I've posted a couple of places:
Enable the "Events Timezone migration"
Log into FB as a user that has admin rights on the FB Page that we want events posted to
Use the APPLICATION's ID to build this link to authorize the
managing of pages
https://www.facebook.com/dialog/oauth?client_id=MY_APP_ID&redirect_uri=MY_SITE_URL&scope=manage_pages,create_event&response_type=token
Exchange token for perm (longer token)
https://graph.facebook.com/oauth/access_token?client_id=MY_APP_ID&client_secret=MY_CLIENT_SECRET&grant_type=fb_exchange_token&fb_exchange_token=(token from step 3)
Visit this page, find the PAGE you want to post and copy the new
access_token https://graph.facebook.com/me/accounts?access_token=
(token from step 4)
Use this last token (from step 5) and the PAGE's ID to post to post
the event per the instructions at
https://developers.facebook.com/docs/reference/api/page/#events
Note that if you create a lot of events, you will "spam" every user who Like'd the page. FB recently added the 'no_feed_story' option to prevent this.

What does it mean for a Facebook Event to be "private"?

I use Facebook-C#-SDK 5.0.3 FacebookClient.Post("me/events", [parameters including "privacy" => "secret"]). The new event shows as "Private Event" on my Facebook. However, my friends see the event appear on their Wall, and when they click on the event they see it as "Public Event".
I am trying to create test events for debugging purposes, but even though I see the event as "Private Event", and when I edit the event the three checkboxes are cleared:
-- Anyone can view and RSVP (public event)
-- Guests can invite Friends
-- Show the guest list on the event page
the event is still visible and announced to all my friends. They can't RSVP, but they do get the UX to post to the event's wall.
Thanks,
Jon
With the SDK the convention is to pass parameters in as a dynamic object or dictionary.
According to a post here the parameter name for setting visibility is 'privacy_type'.
So (without testing) this is how I would go about it in .Net 4:
dynamic parameters = new ExpandoObject();
parameters.privacy_type = "SECRET";
_facebookClient.Post("me/events", parameters);