0

I'm developing an Android App that will manage bookings for a few Outlook meeting rooms (users). The idea is just to display their availability and book a room for a certain amount of time.

So far I have had success getting the events just on my own calendar using Outlook SDK Android.

// logon() {
       ...
       mResolver = new DependencyResolver.Builder(
              new OkHttpTransport().setInterceptor(new LoggingInterceptor()),  
              new GsonSerializer(),
              new AuthenticationCredentials() {
                   @Override
                   public Credentials getCredentials() {
                      return new OAuthCredentials(
                                   authenticationResult.getAccessToken()
                      );
                   }
              }).build();


// onCreate() {

      Futures.addCallback( logon(), new FutureCallback<Boolean>() { 
            @Override
            public void onSuccess(Boolean result) {
                mClient = new OutlookClient(outlookBaseUrl, mResolver);
                getCalendars();
            }

            @Override
            public void onFailure(Throwable t) {
                Log.e("logon", t.getMessage());
            }
      });


      ...

      protected void getCalendars() {
          DateTime startDate = new DateTime(   
              DateTime.parse("2016-02-05T00:00:00Z"));
          DateTime endDate = new DateTime(
              DateTime.parse("2016-02-06T00:00:00Z"));
          Futures.addCallback(
              mClient.getMe()
                      .getCalendarView()
                      .addParameter("startDateTime", startDate)
                      .addParameter("endDateTime", endDate)
                      .read(),

              new FutureCallback<OrcList<Event>>() {
                  @Override
                  public void onSuccess(final OrcList<Event> result) {
                      runOnUiThread(new Runnable() {
                          @Override
                          public void run() {
                              StringBuilder sb = new StringBuilder();
                              ListIterator<Event> events =
                                          result.listIterator();
                              while (events.hasNext()) {
                                  Event event = events.next();
                                  sb.append(event.getSubject() + "\n");
                              }
                              messagesTextView.setText(sb.toString());
                          }
                      });
                  }

                  @Override
                  public void onFailure(Throwable t) {
                      Log.e("Calendar error", t.getLocalizedMessage());
                  }
              }
          );
      }    

Or in alternative using getUsers() instead of getMe(): see here.

So now next steps are:

  1. Do I need an admin user even just to read the meeting rooms calendar or there's some other way?

  2. If I won't be allowed to use an admin account can I manage multiple users with a good usability / performance relying on Oauth flow?

  3. I'm new to Android, is it easier to deal with Outlook REST API or Microsoft Graph?

Thanks

2 Answers 2

1
  1. Today you need to use client credentials flow (AppOnly) if you want your app to access other user's calendar. We are working on an API that will allow to get availability information, more details soon.

  2. Using the OAuth flow you get an access token and a refresh token, the access token is valid for a short period of time and the refresh token can be used to generate new access tokens. The tokens are per user, you basically store the refresh tokens in your app on a per user cache.

  3. From the platform perspective it is the same to interact with the individual Outlook endpoint or the Microsoft Graph. If you app wants to access more than calendar information, like user profile or files, then using Microsoft Graph is the recommendation as you can access data from multiple services under a single endpoint and with a single access token.

3
  • Thank you. One more thing about point 2: The app will fetch updated data at least every 30 seconds but since it will automatically stop working during night time I need to get a new access token every morning at start up of the app, right? Do I need to store all user credentials to be sure to be able to be always logged in? New question:stackoverflow.com/questions/35353319/…. TA again
    – Gabe
    Feb 12, 2016 at 14:48
  • 1
    You don't need to store user credentials, actually we advise against doing this. What you store is the refresh token. Using the refresh token you can go back to the token endpoint and request a new access token Feb 13, 2016 at 0:53
  • With client credentials flow you mean using a service/daemon app? (msdn.microsoft.com/en-us/library/azure/dn645543.aspx) Is it the only way? I've been provided an account with delegate access to the meeting rooms (with "author" permission level) but I'm receiving back 403. :(
    – Gabe
    Mar 13, 2016 at 21:52
1

You need an admin account just to setup the application in Azure. After you set the right Application Permissions you will not need the admin account if you use the app only authorization.

Outlook REST API gives only the current user's information however with Graph API, You can get any meeting room's or any user's events just by sending a request to

https://graph.microsoft.com/v1.0/users/<meetingroom/user email>/calendarView/?endDateTime=2015-12-28T22:23:00Z&startDateTime=2015-12-28T00:00:00Z

Please note that the date format should be in ISO 8601 format.

Hope it helps.

3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.