Version 1.5
Table of contents
Looking to build cool apps that help people work with their Office 365 data? Explore, learn, and understand the Microsoft Graph SDK by using this Snippets sample. This sample shows you how to access multiple resources, including Microsoft Azure Active Directory and Office 365, by making calls to the Microsoft Graph SDK in an Android application.
You can explore the following operations in Microsoft Graph:
Me
Users
Events
Messages
Groups
Drives
To run snippets project, your device must meet the following requirement:
Note: Android Studio may prompt you to install the Android Support Repository 47.0.0+. The project's module build.gradle file logic uses the
implementation
method instead of the oldercompile
method to build the module dependencies. These new build methods depend on the Android Support Repository 47.0.0 or newer.
To use the Microsoft Graph SDK snippets project, you need the following:
Android Java Snippets Sample
. allowPublicClient
property to true Note: In Configure the project, you'll be asked to copy some strings that are generated by the application registration portal. Be sure to stay on application registration page while you configure the project. The strings that you copy from the application registration will be pasted into the source code of the project.
msal{application id as GUID}
) to the clipboard. Be sure you don't copy ://auth
msal0575d7fe-8ec7-4925-9ce2-87074778a039
is copied and ://auth
is ignored.ENTER_YOUR_CLIENT_ID
with the clipboard contents.ENTER_YOUR_CLIENT_ID
with the clipboard contents.After you've built the project you can run it on an emulator or device.
This sample runs commands that create, read, update, or delete data. When running commands that delete or edit data, the sample creates fake entities. The fake entities are deleted or edited so that your actual tenant data is unaffected. The sample will leave behind fake entities on your tenant.
The snippets project uses these classes to manage interactions with Microsoft Graph:
The snippets project is comprised of two modules. The modular design enables you to build a new app based on this sample by importing the modules into your app. After you've imported the modules, use the code in the snippets app module as an example of how to call methods in the other sample modules.
app
. The UI and business logic module. SDK operations are started in the snippet classes in this module.A snippet runs a single operation and returns the results. Snippets are found in the app module. Snippets set the state required to make the calls on the Microsoft Graph service classes described below.
AbstractSnippet
DrivesSnippets
EventsSnippets
GroupsSnippets
MeSnippets
MessageSnippets
UsersSnippets
The authentication methods are found in the AuthenticationManager
class. These methods use the Microsoft Authentication Library (MSAL) for Android to connect to Microsoft Graph.
AuthenticationManager
. Encapsulates user connect and disconnect logic in addition to app authorization.If you'd like to contribute to this sample, see CONTRIBUTING.MD.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.
We'd love to get your feedback about the Microsoft Graph SDK Snippets sample for Android. You can send your feedback to us in the Issues section of this repository.
General questions about Microsoft Graph development should be posted to Stack Overflow. Make sure that your questions are tagged with [microsoftgraph].
Version | Changes |
---|---|
1.0 | Initial release |
1.5 | - MSAL authentication library replaced ADAL authentication library - Microsoft Graph SDK version 1.5 |
Copyright (c) 2019 Microsoft. All rights reserved.