apiko-dev / azure-resource-office-365

Enhances the azure-active-directory & accounts-azure-active-directory packages, allowing users to authorize themselves against the office 365 rest APIs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

azure-resource-office-365

Enhances the azure-active-directory & accounts-azure-active-directory packages, allowing users to authorize themselves against the office 365 rest APIs.

Configuration

You will need to assign your Azure AD application the necessary permissions. This guide describes the process pretty well.

Example

The following demonstrates how to register a Meteor method called "getEvents" that would call the office 365 rest api to fetch the current user's upcoming events. You will need to assign the Calendar.Read permission to your Azure AD application for this to work.

Meteor.methods({
    "getEvents": function () {
        var url = "https://outlook.office365.com/api/v1.0/me/events";
        var user = Meteor.users.findOne(this.userId);
        var accessToken = AzureAd.resources.getOrUpdateUserAccessToken(AzureAd.resources.office365.friendlyName, user);
        return AzureAd.http.callAuthenticated("GET", url, accessToken);
    }
});

The method could then be called on the client side, like this:

Meteor.call("getEvents", function(err, calendars){
    console.log(calendars);
});

About

Enhances the azure-active-directory & accounts-azure-active-directory packages, allowing users to authorize themselves against the office 365 rest APIs


Languages

Language:JavaScript 100.0%