Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.

microsoftgraph/ios-objectivec-connect-rest-sample

 
 

Repository files navigation

Office 365 Connect Sample for iOS Using Microsoft Graph

Connecting to Office 365 is the first step every iOS app must take to start working with Office 365 services and data. This sample shows how to connect and then call one API through Microsoft Graph (previously called Office 365 unified API)

Note: Try out the Get started with Office 365 APIs page which simplifies registration so you can get this sample running faster.

Prerequisites

  • Xcode from Apple

  • Installation of CocoaPods as a dependency manager.

  • An Office 365 account. You can sign up for an Office 365 Developer subscription that includes the resources that you need to start building Office 365 apps.

    Note: If you already have a subscription, the previous link sends you to a page with the message Sorry, you can’t add that to your current account. In that case, use an account from your current Office 365 subscription.

  • A Microsoft Azure tenant to register your application. Azure Active Directory (AD) provides identity services that applications use for authentication and authorization. A trial subscription can be acquired here: Microsoft Azure.

    Important: You will also need to ensure your Azure subscription is bound to your Office 365 tenant. To do this, see the Active Directory team's blog post, Creating and Managing Multiple Windows Azure Active Directories. The section Adding a new directory will explain how to do this. You can also see Set up your Office 365 development environment and the section Associate your Office 365 account with Azure AD to create and manage apps for more information.

  • A client id and redirect uri values of an application registered in Azure. This sample application must be granted the Send mail as signed-in user and Sign in and read user profile permissions for the Microsoft Graph API application. To create the registration, see Register your native app with the Azure Management Portal in Manually register your app with Azure AD so it can access Office 365 APIs and grant proper permissions in the sample wiki to apply the proper permissions to it.

Running this sample in Xcode

  1. Clone this repository

  2. Use CocoaPods to import the Active Directory Authentication Library (ADAL) iOS dependency:

      pod 'ADALiOS', '= 1.2.4'
    

This sample app already contains a podfile that will get the ADAL components (pods) into the project. Simply navigate to the project From Terminal and run:

    pod install

For more information, see Using CocoaPods in Additional Resources

  1. Open O365-iOS-Unified-API-Connect.xcworkspace

  2. Open ConnectViewController.m. You'll see that the ClientID and RedirectUri values can be added to the top of the file. Supply the necessary values here:

     // You will set your application's clientId and redirect URI. 
     NSString * const kRedirectUri = @"ENTER_REDIRECT_URI_HERE";
     NSString * const kClientId    = @"ENTER_CLIENT_ID_HERE";
     NSString * const kAuthority   = @"https://login.microsoftonline.com/common";
     NSString * const kResourceId  = @"https://graph.microsoft.com";
    

    Note: If you have don't have CLIENT_ID and REDIRECT_URI values, add a native client application in Azure and take note of the CLIENT_ID and REDIRECT_URI.

  3. Run the sample.

To learn more about the sample, visit our understanding the code wiki page.

Questions and comments

We'd love to get your feedback about the Office 365 iOS Microsoft Graph Connect project. You can send your questions and suggestions to us in the Issues section of this repository.

Questions about Office 365 development in general should be posted to Stack Overflow. Make sure that your questions or comments are tagged with [Office365] and [MicrosoftGraph].

Additional resources

Copyright

Copyright (c) 2015 Microsoft. All rights reserved.