├── .gitattributes ├── .gitignore ├── CONTRIBUTING.md ├── LICENSE ├── O365-UWP-Unified-API-Connect.sln ├── O365-UWP-Unified-API-Connect ├── App.xaml ├── App.xaml.cs ├── Assets │ ├── LockScreenLogo.scale-200.png │ ├── Resources.resw │ ├── SmallLogo.scale-100.png │ ├── SplashScreen.scale-100.png │ ├── SplashScreen.scale-200.png │ ├── SplashScreenImage.png │ ├── Square150x150Logo.scale-100.png │ ├── Square150x150Logo.scale-200.png │ ├── Square44x44Logo.scale-200.png │ ├── Square44x44Logo.targetsize-24_altform-unplated.png │ ├── StoreLogo.png │ ├── StoreLogo.scale-100.png │ └── Wide310x150Logo.scale-200.png ├── AuthenticationHelper.cs ├── MailHelper.cs ├── MainPage.xaml ├── MainPage.xaml.cs ├── O365-UWP-Unified-API-Connect.csproj ├── O365-UWP-Unified-API-Connect.nuget.props ├── O365-UWP-Unified-API-Connect.nuget.targets ├── Package.appxmanifest ├── Properties │ ├── AssemblyInfo.cs │ └── Default.rd.xml ├── Service References │ └── Office365 │ │ └── ConnectedService.json ├── project.json ├── project.lock.json └── test.jpg ├── README-Localized ├── README-de-de.md ├── README-es-es.md ├── README-fr-fr.md ├── README-ja-jp.md ├── README-pt-br.md ├── README-ru-ru.md ├── README-zh-cn.md └── README-zh-tw.md ├── README.md └── readme-images ├── ClientTenant.png ├── SignedIn.png ├── SignedOut.png ├── appId_and_redirectURI.png └── copy_icon.png /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | build/ 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 24 | 25 | # Visual Studo 2015 cache/options directory 26 | .vs/ 27 | 28 | # MSTest test Results 29 | [Tt]est[Rr]esult*/ 30 | [Bb]uild[Ll]og.* 31 | 32 | # NUNIT 33 | *.VisualState.xml 34 | TestResult.xml 35 | 36 | # Build Results of an ATL Project 37 | [Dd]ebugPS/ 38 | [Rr]eleasePS/ 39 | dlldata.c 40 | 41 | *_i.c 42 | *_p.c 43 | *_i.h 44 | *.ilk 45 | *.meta 46 | *.obj 47 | *.pch 48 | *.pdb 49 | *.pgc 50 | *.pgd 51 | *.rsp 52 | *.sbr 53 | *.tlb 54 | *.tli 55 | *.tlh 56 | *.tmp 57 | *.tmp_proj 58 | *.log 59 | *.vspscc 60 | *.vssscc 61 | .builds 62 | *.pidb 63 | *.svclog 64 | *.scc 65 | 66 | # Chutzpah Test files 67 | _Chutzpah* 68 | 69 | # Visual C++ cache files 70 | ipch/ 71 | *.aps 72 | *.ncb 73 | *.opensdf 74 | *.sdf 75 | *.cachefile 76 | 77 | # Visual Studio profiler 78 | *.psess 79 | *.vsp 80 | *.vspx 81 | 82 | # TFS 2012 Local Workspace 83 | $tf/ 84 | 85 | # Guidance Automation Toolkit 86 | *.gpState 87 | 88 | # ReSharper is a .NET coding add-in 89 | _ReSharper*/ 90 | *.[Rr]e[Ss]harper 91 | *.DotSettings.user 92 | 93 | # JustCode is a .NET coding addin-in 94 | .JustCode 95 | 96 | # TeamCity is a build add-in 97 | _TeamCity* 98 | 99 | # DotCover is a Code Coverage Tool 100 | *.dotCover 101 | 102 | # NCrunch 103 | _NCrunch_* 104 | .*crunch*.local.xml 105 | 106 | # MightyMoose 107 | *.mm.* 108 | AutoTest.Net/ 109 | 110 | # Web workbench (sass) 111 | .sass-cache/ 112 | 113 | # Installshield output folder 114 | [Ee]xpress/ 115 | 116 | # DocProject is a documentation generator add-in 117 | DocProject/buildhelp/ 118 | DocProject/Help/*.HxT 119 | DocProject/Help/*.HxC 120 | DocProject/Help/*.hhc 121 | DocProject/Help/*.hhk 122 | DocProject/Help/*.hhp 123 | DocProject/Help/Html2 124 | DocProject/Help/html 125 | 126 | # Click-Once directory 127 | publish/ 128 | 129 | # Publish Web Output 130 | *.[Pp]ublish.xml 131 | *.azurePubxml 132 | # TODO: Comment the next line if you want to checkin your web deploy settings 133 | # but database connection strings (with potential passwords) will be unencrypted 134 | *.pubxml 135 | *.publishproj 136 | 137 | # NuGet Packages 138 | *.nupkg 139 | # The packages folder can be ignored because of Package Restore 140 | **/packages/* 141 | # except build/, which is used as an MSBuild target. 142 | !**/packages/build/ 143 | # Uncomment if necessary however generally it will be regenerated when needed 144 | #!**/packages/repositories.config 145 | 146 | # Windows Azure Build Output 147 | csx/ 148 | *.build.csdef 149 | 150 | # Windows Store app package directory 151 | AppPackages/ 152 | 153 | # Others 154 | *.[Cc]ache 155 | ClientBin/ 156 | [Ss]tyle[Cc]op.* 157 | ~$* 158 | *~ 159 | *.dbmdl 160 | *.dbproj.schemaview 161 | *.pfx 162 | *.publishsettings 163 | node_modules/ 164 | bower_components/ 165 | 166 | # RIA/Silverlight projects 167 | Generated_Code/ 168 | 169 | # Backup & report files from converting an old project file 170 | # to a newer Visual Studio version. Backup files are not needed, 171 | # because we have git ;-) 172 | _UpgradeReport_Files/ 173 | Backup*/ 174 | UpgradeLog*.XML 175 | UpgradeLog*.htm 176 | 177 | # SQL Server files 178 | *.mdf 179 | *.ldf 180 | 181 | # Business Intelligence projects 182 | *.rdl.data 183 | *.bim.layout 184 | *.bim_*.settings 185 | 186 | # Microsoft Fakes 187 | FakesAssemblies/ 188 | 189 | # Node.js Tools for Visual Studio 190 | .ntvs_analysis.dat 191 | 192 | # Visual Studio 6 build log 193 | *.plg 194 | 195 | # Visual Studio 6 workspace options file 196 | *.opt 197 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Contribute to this documentation 2 | 3 | Thank you for your interest in our documentation! 4 | 5 | * [Ways to contribute](#ways-to-contribute) 6 | * [Contribute using GitHub](#contribute-using-github) 7 | * [Contribute using Git](#contribute-using-git) 8 | * [How to use Markdown to format your topic](#how-to-use-markdown-to-format-your-topic) 9 | * [FAQ](#faq) 10 | * [More resources](#more-resources) 11 | 12 | ## Ways to contribute 13 | 14 | Here are some ways you can contribute to this documentation: 15 | 16 | * To make small changes to an article, [Contribute using GitHub](#contribute-using-github). 17 | * To make large changes, or changes that involve code, [Contribute using Git](#contribute-using-git). 18 | * Report documentation bugs via GitHub Issues 19 | * Request new documentation at the [Office Developer Platform UserVoice](http://officespdev.uservoice.com) site. 20 | 21 | ## Contribute using GitHub 22 | 23 | Use GitHub to contribute to this documentation without having to clone the repo to your desktop. This is the easiest way to create a pull request in this repository. Use this method to make a minor change that doesn't involve code changes. 24 | 25 | **Note** Using this method allows you to contribute to one article at a time. 26 | 27 | ### To Contribute using GitHub 28 | 29 | 1. Find the article you want to contribute to on GitHub. 30 | 31 | If the article is in MSDN, choose the **suggest and submit changes** link in the **Contribute to this content** section and you'll be taken to the same article on GitHub. 32 | 2. Once you are on the article in GitHub, sign in to GitHub (get a free account [Join GitHub](https://github.com/join). 33 | 3. Choose the **pencil icon** (edit the file in your fork of this project) and make your changes in the **<>Edit file** window. 34 | 4. Scroll to the bottom and enter a description. 35 | 5. Choose **Propose file change**>**Create pull request**. 36 | 37 | You now have successfully submitted a pull request. Pull requests are typically reviewed within 10 business days. 38 | 39 | 40 | ## Contribute using Git 41 | 42 | Use Git to contribute substantive changes, such as: 43 | 44 | * Contributing code. 45 | * Contributing changes that affect meaning. 46 | * Contributing large changes to text. 47 | * Adding new topics. 48 | 49 | ### To Contribute using Git 50 | 51 | 1. If you don't have a GitHub account, set one up at [GitHub](https://github.com/join). 52 | 2. After you have an account, install Git on your computer. Follow the steps in [Setting up Git Tutorial](https://help.github.com/articles/set-up-git/). 53 | 3. To submit a pull request using Git, follow the steps in [Use GitHub, Git, and this repository](#use-github-git-and-this-repository). 54 | 4. You will be asked to sign the Contributor's License Agreement if you are: 55 | 56 | * A member of the Microsoft Open Technologies group. 57 | * A contributors who doesn't work for Microsoft. 58 | 59 | As a community member, you must sign the Contribution License Agreement (CLA) before you can contribute large submissions to a project. You only need to complete and submit the documentation once. Carefully review the document. You may be required to have your employer sign the document. 60 | 61 | Signing the CLA does not grant you rights to commit to the main repository, but it does mean that the Office Developer and Office Developer Content Publishing teams will be able to review and approve your contributions. You will be credited for your submissions. 62 | 63 | Pull requests are typically reviewed within 10 business days. 64 | 65 | ## Use GitHub, Git, and this repository 66 | 67 | **Note:** Most of the information in this section can be found in [GitHub Help] articles. If you're familiar with Git and GitHub, skip to the **Contribute and edit content** section for the specifics of the code/content flow of this repository. 68 | 69 | ### To set up your fork of the repository 70 | 71 | 1. Set up a GitHub account so you can contribute to this project. If you haven't done this, go to [GitHub](https://github.com/join) and do it now. 72 | 2. Install Git on your computer. Follow the steps in the [Setting up Git Tutorial] [Set Up Git]. 73 | 3. Create your own fork of this repository. To do this, at the top of the page, choose the **Fork** button. 74 | 4. Copy your fork to your computer. To do this, open Git Bash. At the command prompt enter: 75 | 76 | git clone https://github.com//.git 77 | 78 | Next, create a reference to the root repository by entering these commands: 79 | 80 | cd 81 | git remote add upstream https://github.com/microsoftgraph/.git 82 | git fetch upstream 83 | 84 | Congratulations! You've now set up your repository. You won't need to repeat these steps again. 85 | 86 | ### Contribute and edit content 87 | 88 | To make the contribution process as seamless as possible, follow these steps. 89 | 90 | #### To contribute and edit content 91 | 92 | 1. Create a new branch. 93 | 2. Add new content or edit existing content. 94 | 3. Submit a pull request to the main repository. 95 | 4. Delete the branch. 96 | 97 | **Important** Limit each branch to a single concept/article to streamline the work flow and reduce the chance of merge conflicts. Content appropriate for a new branch includes: 98 | 99 | * A new article. 100 | * Spelling and grammar edits. 101 | * Applying a single formatting change across a large set of articles (for example, applying a new copyright footer). 102 | 103 | #### To create a new branch 104 | 105 | 1. Open Git Bash. 106 | 2. At the Git Bash command prompt, type `git pull upstream master:`. This creates a new branch locally that is copied from the latest MicrosoftGraph master branch. 107 | 3. At the Git Bash command prompt, type `git push origin `. This alerts GitHub to the new branch. You should now see the new branch in your fork of the repository on GitHub. 108 | 4. At the Git Bash command prompt, type `git checkout ` to switch to your new branch. 109 | 110 | #### Add new content or edit existing content 111 | 112 | You navigate to the repository on your computer by using File Explorer. The repository files are in `C:\Users\\`. 113 | 114 | To edit files, open them in an editor of your choice and modify them. To create a new file, use the editor of your choice and save the new file in the appropriate location in your local copy of the repository. While working, save your work frequently. 115 | 116 | The files in `C:\Users\\` are a working copy of the new branch that you created in your local repository. Changing anything in this folder doesn't affect the local repository until you commit a change. To commit a change to the local repository, type the following commands in GitBash: 117 | 118 | git add . 119 | git commit -v -a -m "" 120 | 121 | The `add` command adds your changes to a staging area in preparation for committing them to the repository. The period after the `add` command specifies that you want to stage all of the files that you added or modified, checking subfolders recursively. (If you don't want to commit all of the changes, you can add specific files. You can also undo a commit. For help, type `git add -help` or `git status`.) 122 | 123 | The `commit` command applies the staged changes to the repository. The switch `-m` means you are providing the commit comment in the command line. The -v and -a switches can be omitted. The -v switch is for verbose output from the command, and -a does what you already did with the add command. 124 | 125 | You can commit multiple times while you are doing your work, or you can commit once when you're done. 126 | 127 | #### Submit a pull request to the main repository 128 | 129 | When you're finished with your work and are ready to have it merged into the main repository, follow these steps. 130 | 131 | #### To submit a pull request to the main repository 132 | 133 | 1. In the Git Bash command prompt, type `git push origin `. In your local repository, `origin` refers to your GitHub repository that you cloned the local repository from. This command pushes the current state of your new branch, including all commits made in the previous steps, to your GitHub fork. 134 | 2. On the GitHub site, navigate in your fork to the new branch. 135 | 3. Choose the **Pull Request** button at the top of the page. 136 | 4. Verify the Base branch is `microsoftgraph/@master` and the Head branch is `/@`. 137 | 5. Choose the **Update Commit Range** button. 138 | 6. Add a title to your pull request, and describe all the changes you're making. 139 | 7. Submit the pull request. 140 | 141 | One of the site administrators will process your pull request. Your pull request will surface on the microsoftgraph/ site under Issues. When the pull request is accepted, the issue will be resolved. 142 | 143 | #### Create a new branch after merge 144 | 145 | After a branch is successfully merged (that is, your pull request is accepted), don't continue working in that local branch. This can lead to merge conflicts if you submit another pull request. To do another update, create a new local branch from the successfully merged upstream branch, and then delete your initial local branch. 146 | 147 | For example, if your local branch X was successfully merged into the OfficeDev/microsoft-graph-docs master branch and you want to make additional updates to the content that was merged. Create a new local branch, X2, from the OfficeDev/microsoft-graph-docs master branch. To do this, open GitBash and execute the following commands: 148 | 149 | cd microsoft-graph-docs 150 | git pull upstream master:X2 151 | git push origin X2 152 | 153 | You now have local copies (in a new local branch) of the work that you submitted in branch X. The X2 branch also contains all the work other writers have merged, so if your work depends on others' work (for example, shared images), it is available in the new branch. You can verify that your previous work (and others' work) is in the branch by checking out the new branch... 154 | 155 | git checkout X2 156 | 157 | ...and verifying the content. (The `checkout` command updates the files in `C:\Users\\microsoft-graph-docs` to the current state of the X2 branch.) Once you check out the new branch, you can make updates to the content and commit them as usual. However, to avoid working in the merged branch (X) by mistake, it's best to delete it (see the following **Delete a branch** section). 158 | 159 | #### Delete a branch 160 | 161 | Once your changes are successfully merged into the main repository, delete the branch you used because you no longer need it. Any additional work should be done in a new branch. 162 | 163 | #### To delete a branch 164 | 165 | 1. In the Git Bash command prompt, type `git checkout master`. This ensures that you aren't in the branch to be deleted (which isn't allowed). 166 | 2. Next, at the command prompt, type `git branch -d `. This deletes the branch on your computer only if it has been successfully merged to the upstream repository. (You can override this behavior with the `–D` flag, but first be sure you want to do this.) 167 | 3. Finally, type `git push origin :` at the command prompt (a space before the colon and no space after it). This will delete the branch on your github fork. 168 | 169 | Congratulations, you have successfully contributed to the project! 170 | 171 | ## How to use Markdown to format your topic 172 | 173 | ### Article template 174 | 175 | The [markdown template](/articles/0-markdown-template-for-new-articles.md) contains the basic Markdown for a topic that includes a table of contents, sections with subheadings, links to other Office developer topics, links to other sites, bold text, italic text, numbered and bulleted lists, code snippets, and images. 176 | 177 | 178 | ### Standard Markdown 179 | 180 | All of the articles in this repository use Markdown. A complete introduction (and listing of all the syntax) can be found at [Markdown Home] []. 181 | 182 | ## FAQ 183 | 184 | ### How do I get a GitHub account? 185 | 186 | Fill out the form at [Join GitHub](https://github.com/join) to open a free GitHub account. 187 | 188 | ### Where do I get a Contributor's License Agreement? 189 | 190 | You will automatically be sent a notice that you need to sign the Contributor's License Agreement (CLA) if your pull request requires one. 191 | 192 | As a community member, **you must sign the Contribution License Agreement (CLA) before you can contribute large submissions to this project**. You only need complete and submit the documentation once. Carefully review the document. You may be required to have your employer sign the document. 193 | 194 | ### What happens with my contributions? 195 | 196 | When you submit your changes, via a pull request, our team will be notified and will review your pull request. You will receive notifications about your pull request from GitHub; you may also be notified by someone from our team if we need more information. We reserve the right to edit your submission for legal, style, clarity, or other issues. 197 | 198 | ### Can I become an approver for this repository's GitHub pull requests? 199 | 200 | Currently, we are not allowing external contributors to approve pull requests in this repository. 201 | 202 | ### How soon will I get a response about my change request or issue? 203 | 204 | We typically review pull requests and respond to issues within 10 business days. 205 | 206 | ## More resources 207 | 208 | * To learn more about Markdown, go to the Git creator's site [Daring Fireball]. 209 | * To learn more about using Git and GitHub, first check out the [GitHub Help section] [GitHub Help]. 210 | 211 | [GitHub Home]: http://github.com 212 | [GitHub Help]: http://help.github.com/ 213 | [Set Up Git]: http://help.github.com/win-set-up-git/ 214 | [Markdown Home]: http://daringfireball.net/projects/markdown/ 215 | [Daring Fireball]: http://daringfireball.net/ 216 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Microsoft Corporation 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /O365-UWP-Unified-API-Connect.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.23107.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "O365-UWP-Unified-API-Connect", "O365-UWP-Unified-API-Connect\O365-UWP-Unified-API-Connect.csproj", "{45AE643D-C990-41EA-B797-0A5F6FE85899}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|ARM = Debug|ARM 11 | Debug|x64 = Debug|x64 12 | Debug|x86 = Debug|x86 13 | Release|ARM = Release|ARM 14 | Release|x64 = Release|x64 15 | Release|x86 = Release|x86 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {45AE643D-C990-41EA-B797-0A5F6FE85899}.Debug|ARM.ActiveCfg = Debug|ARM 19 | {45AE643D-C990-41EA-B797-0A5F6FE85899}.Debug|ARM.Build.0 = Debug|ARM 20 | {45AE643D-C990-41EA-B797-0A5F6FE85899}.Debug|ARM.Deploy.0 = Debug|ARM 21 | {45AE643D-C990-41EA-B797-0A5F6FE85899}.Debug|x64.ActiveCfg = Debug|x64 22 | {45AE643D-C990-41EA-B797-0A5F6FE85899}.Debug|x64.Build.0 = Debug|x64 23 | {45AE643D-C990-41EA-B797-0A5F6FE85899}.Debug|x64.Deploy.0 = Debug|x64 24 | {45AE643D-C990-41EA-B797-0A5F6FE85899}.Debug|x86.ActiveCfg = Debug|x86 25 | {45AE643D-C990-41EA-B797-0A5F6FE85899}.Debug|x86.Build.0 = Debug|x86 26 | {45AE643D-C990-41EA-B797-0A5F6FE85899}.Debug|x86.Deploy.0 = Debug|x86 27 | {45AE643D-C990-41EA-B797-0A5F6FE85899}.Release|ARM.ActiveCfg = Release|ARM 28 | {45AE643D-C990-41EA-B797-0A5F6FE85899}.Release|ARM.Build.0 = Release|ARM 29 | {45AE643D-C990-41EA-B797-0A5F6FE85899}.Release|ARM.Deploy.0 = Release|ARM 30 | {45AE643D-C990-41EA-B797-0A5F6FE85899}.Release|x64.ActiveCfg = Release|x64 31 | {45AE643D-C990-41EA-B797-0A5F6FE85899}.Release|x64.Build.0 = Release|x64 32 | {45AE643D-C990-41EA-B797-0A5F6FE85899}.Release|x64.Deploy.0 = Release|x64 33 | {45AE643D-C990-41EA-B797-0A5F6FE85899}.Release|x86.ActiveCfg = Release|x86 34 | {45AE643D-C990-41EA-B797-0A5F6FE85899}.Release|x86.Build.0 = Release|x86 35 | {45AE643D-C990-41EA-B797-0A5F6FE85899}.Release|x86.Deploy.0 = Release|x86 36 | EndGlobalSection 37 | GlobalSection(SolutionProperties) = preSolution 38 | HideSolutionNode = FALSE 39 | EndGlobalSection 40 | EndGlobal 41 | -------------------------------------------------------------------------------- /O365-UWP-Unified-API-Connect/App.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 9 | 10 | 11 | 12 | ENTER_YOUR_CLIENT_ID 13 | urn:ietf:wg:oauth:2.0:oob 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /O365-UWP-Unified-API-Connect/App.xaml.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 2 | using System; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using System.Linq; 6 | using System.Runtime.InteropServices.WindowsRuntime; 7 | using Windows.ApplicationModel; 8 | using Windows.ApplicationModel.Activation; 9 | using Windows.Foundation; 10 | using Windows.Foundation.Collections; 11 | using Windows.UI.Xaml; 12 | using Windows.UI.Xaml.Controls; 13 | using Windows.UI.Xaml.Controls.Primitives; 14 | using Windows.UI.Xaml.Data; 15 | using Windows.UI.Xaml.Input; 16 | using Windows.UI.Xaml.Media; 17 | using Windows.UI.Xaml.Navigation; 18 | 19 | namespace O365_UWP_Unified_API_Connect 20 | { 21 | /// 22 | /// Provides application-specific behavior to supplement the default Application class. 23 | /// 24 | sealed partial class App : Application 25 | { 26 | /// 27 | /// Initializes the singleton application object. This is the first line of authored code 28 | /// executed, and as such is the logical equivalent of main() or WinMain(). 29 | /// 30 | public App() 31 | { 32 | this.InitializeComponent(); 33 | this.Suspending += OnSuspending; 34 | } 35 | 36 | /// 37 | /// Invoked when the application is launched normally by the end user. Other entry points 38 | /// will be used such as when the application is launched to open a specific file. 39 | /// 40 | /// Details about the launch request and process. 41 | protected override void OnLaunched(LaunchActivatedEventArgs e) 42 | { 43 | 44 | Frame rootFrame = Window.Current.Content as Frame; 45 | 46 | // Do not repeat app initialization when the Window already has content, 47 | // just ensure that the window is active 48 | if (rootFrame == null) 49 | { 50 | // Create a Frame to act as the navigation context and navigate to the first page 51 | rootFrame = new Frame(); 52 | 53 | rootFrame.NavigationFailed += OnNavigationFailed; 54 | 55 | if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) 56 | { 57 | //TODO: Load state from previously suspended application 58 | } 59 | 60 | // Place the frame in the current Window 61 | Window.Current.Content = rootFrame; 62 | } 63 | 64 | if (rootFrame.Content == null) 65 | { 66 | // When the navigation stack isn't restored navigate to the first page, 67 | // configuring the new page by passing required information as a navigation 68 | // parameter 69 | rootFrame.Navigate(typeof(MainPage), e.Arguments); 70 | } 71 | // Ensure the current window is active 72 | Window.Current.Activate(); 73 | } 74 | 75 | /// 76 | /// Invoked when Navigation to a certain page fails 77 | /// 78 | /// The Frame which failed navigation 79 | /// Details about the navigation failure 80 | void OnNavigationFailed(object sender, NavigationFailedEventArgs e) 81 | { 82 | throw new Exception("Failed to load Page " + e.SourcePageType.FullName); 83 | } 84 | 85 | /// 86 | /// Invoked when application execution is being suspended. Application state is saved 87 | /// without knowing whether the application will be terminated or resumed with the contents 88 | /// of memory still intact. 89 | /// 90 | /// The source of the suspend request. 91 | /// Details about the suspend request. 92 | private void OnSuspending(object sender, SuspendingEventArgs e) 93 | { 94 | var deferral = e.SuspendingOperation.GetDeferral(); 95 | //TODO: Save application state and stop any background activity 96 | deferral.Complete(); 97 | } 98 | } 99 | } 100 | //********************************************************* 101 | // 102 | //O365-UWP-Microsoft-Graph-Connect, https://github.com/OfficeDev/O365-UWP-Microsoft-Graph-Connect 103 | // 104 | //Copyright (c) Microsoft Corporation 105 | //All rights reserved. 106 | // 107 | // MIT License: 108 | // Permission is hereby granted, free of charge, to any person obtaining 109 | // a copy of this software and associated documentation files (the 110 | // ""Software""), to deal in the Software without restriction, including 111 | // without limitation the rights to use, copy, modify, merge, publish, 112 | // distribute, sublicense, and/or sell copies of the Software, and to 113 | // permit persons to whom the Software is furnished to do so, subject to 114 | // the following conditions: 115 | 116 | // The above copyright notice and this permission notice shall be 117 | // included in all copies or substantial portions of the Software. 118 | 119 | // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, 120 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 121 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 122 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 123 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 124 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 125 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 126 | // 127 | //********************************************************* -------------------------------------------------------------------------------- /O365-UWP-Unified-API-Connect/Assets/LockScreenLogo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoftgraph/uwp-csharp-connect-rest-sample/a8707527771ff1b90e562b0d41a743cef7c0acb3/O365-UWP-Unified-API-Connect/Assets/LockScreenLogo.scale-200.png -------------------------------------------------------------------------------- /O365-UWP-Unified-API-Connect/Assets/Resources.resw: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | Oops! 122 | We couldn't connect to Office 365. Check your debug output for errors. 123 | 124 | 125 | Tap the following button to connect to Office 365. 126 | 127 | 128 | <html><head> 129 | <meta http-equiv=\'Content-Type\' content=\'text/html; charset=us-ascii\'> 130 | <title></title> 131 | </head> 132 | <body style=\'font-family:calibri\'> 133 | <h2>Congratulations!</h2> 134 | <p>This is a message from the Microsoft Graph Connect Sample. You are well on your way to incorporating Microsoft Graph endpoints in your apps.</p><a href=\'{0}\'>See the photo you just uploaded!</a> 135 | <h3>What&#8217;s next?</h3><ul> 136 | <li>Check out <a href=\'https://developer.microsoft.com/graph\'>developer.microsoft.com/graph</a> to start building Microsoft Graph apps today with all the latest tools, templates, and guidance to get started quickly.</li> 137 | <li>Use the <a href=\'https://developer.microsoft.com/graph/graph-explorer\'>Graph Explorer</a> to explore the rest of the APIs and start your testing.</li> 138 | <li>Browse other <a href=\'https://github.com/microsoftgraph/\'>samples on GitHub</a> to see more of the APIs in action.</li> 139 | </ul> 140 | <h3>Give us feedback</h3> 141 | <p>If you have any trouble running this sample, please <a href=\'https://github.com/microsoftgraph/uwp-csharp-connect-sample/issues\'> 142 | log an issue</a> on our repository.</p><p>For general questions about the Microsoft Graph API, post to <a href=\'https://stackoverflow.com/questions/tagged/microsoftgraph\'>Stack Overflow</a>. Make sure that your questions or comments are tagged with [microsoftgraph].</p> 143 | <p>Thanks, and happy coding!<br> 144 | &nbsp;&nbsp;&nbsp;&nbsp;Your Microsoft Graph samples development team </p> 145 | <div style=\'text-align:center; font-family:calibri\'> 146 | <table style=\'width:100%; font-family:calibri\'> 147 | <tbody> 148 | <tr> 149 | <td><a href=\'https://github.com/microsoftgraph/uwp-csharp-connect-sample\'>See on GitHub</a> 150 | </td> 151 | <td><a href=\'https://office365.uservoice.com\'>Suggest on UserVoice</a> 152 | </td> 153 | <td><a href=\'https://twitter.com/share?text=I%20just%20started%20developing%20apps%20for%20%23ASP.NET%20using%20the%20%23MicrosoftGraph%20Connect%20app%20%40OfficeDev&amp;url=https://github.com/microsoftgraph/uwp-csharp-connect-sample\'>Share on Twitter</a> 154 | </td> 155 | </tr> 156 | </tbody> 157 | </table> 158 | </div> 159 | </body> 160 | </html> 161 | 162 | 163 | Oops! 164 | 165 | We couldn't send an mail. Check your debug output for errors. 166 | 167 | 168 | Hi from the Microsoft Graph Connect sample. 169 | 170 | 171 | Oops - It looks like this app is not registered with Office 365, because we don't see a client id in App.xaml. To run this sample, register it with Office 365. See Readme for more info. 172 | 173 | 174 | You're now connected to Microsoft Graph. Tap "send mail" to send a message from your account using Microsoft Graph. 175 | 176 | 177 | We successfully sent an email to {0} ! 178 | 179 | -------------------------------------------------------------------------------- /O365-UWP-Unified-API-Connect/Assets/SmallLogo.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoftgraph/uwp-csharp-connect-rest-sample/a8707527771ff1b90e562b0d41a743cef7c0acb3/O365-UWP-Unified-API-Connect/Assets/SmallLogo.scale-100.png -------------------------------------------------------------------------------- /O365-UWP-Unified-API-Connect/Assets/SplashScreen.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoftgraph/uwp-csharp-connect-rest-sample/a8707527771ff1b90e562b0d41a743cef7c0acb3/O365-UWP-Unified-API-Connect/Assets/SplashScreen.scale-100.png -------------------------------------------------------------------------------- /O365-UWP-Unified-API-Connect/Assets/SplashScreen.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoftgraph/uwp-csharp-connect-rest-sample/a8707527771ff1b90e562b0d41a743cef7c0acb3/O365-UWP-Unified-API-Connect/Assets/SplashScreen.scale-200.png -------------------------------------------------------------------------------- /O365-UWP-Unified-API-Connect/Assets/SplashScreenImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoftgraph/uwp-csharp-connect-rest-sample/a8707527771ff1b90e562b0d41a743cef7c0acb3/O365-UWP-Unified-API-Connect/Assets/SplashScreenImage.png -------------------------------------------------------------------------------- /O365-UWP-Unified-API-Connect/Assets/Square150x150Logo.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoftgraph/uwp-csharp-connect-rest-sample/a8707527771ff1b90e562b0d41a743cef7c0acb3/O365-UWP-Unified-API-Connect/Assets/Square150x150Logo.scale-100.png -------------------------------------------------------------------------------- /O365-UWP-Unified-API-Connect/Assets/Square150x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoftgraph/uwp-csharp-connect-rest-sample/a8707527771ff1b90e562b0d41a743cef7c0acb3/O365-UWP-Unified-API-Connect/Assets/Square150x150Logo.scale-200.png -------------------------------------------------------------------------------- /O365-UWP-Unified-API-Connect/Assets/Square44x44Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoftgraph/uwp-csharp-connect-rest-sample/a8707527771ff1b90e562b0d41a743cef7c0acb3/O365-UWP-Unified-API-Connect/Assets/Square44x44Logo.scale-200.png -------------------------------------------------------------------------------- /O365-UWP-Unified-API-Connect/Assets/Square44x44Logo.targetsize-24_altform-unplated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoftgraph/uwp-csharp-connect-rest-sample/a8707527771ff1b90e562b0d41a743cef7c0acb3/O365-UWP-Unified-API-Connect/Assets/Square44x44Logo.targetsize-24_altform-unplated.png -------------------------------------------------------------------------------- /O365-UWP-Unified-API-Connect/Assets/StoreLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoftgraph/uwp-csharp-connect-rest-sample/a8707527771ff1b90e562b0d41a743cef7c0acb3/O365-UWP-Unified-API-Connect/Assets/StoreLogo.png -------------------------------------------------------------------------------- /O365-UWP-Unified-API-Connect/Assets/StoreLogo.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoftgraph/uwp-csharp-connect-rest-sample/a8707527771ff1b90e562b0d41a743cef7c0acb3/O365-UWP-Unified-API-Connect/Assets/StoreLogo.scale-100.png -------------------------------------------------------------------------------- /O365-UWP-Unified-API-Connect/Assets/Wide310x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoftgraph/uwp-csharp-connect-rest-sample/a8707527771ff1b90e562b0d41a743cef7c0acb3/O365-UWP-Unified-API-Connect/Assets/Wide310x150Logo.scale-200.png -------------------------------------------------------------------------------- /O365-UWP-Unified-API-Connect/AuthenticationHelper.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 2 | 3 | using System; 4 | using System.Diagnostics; 5 | using System.Net.Http; 6 | using System.Linq; 7 | using System.Threading.Tasks; 8 | using Windows.Security.Authentication.Web; 9 | using Windows.Security.Authentication.Web.Core; 10 | using Windows.Security.Credentials; 11 | using Windows.Storage; 12 | using Microsoft.Identity.Client; 13 | 14 | namespace O365_UWP_Unified_API_Connect 15 | { 16 | public class AuthenticationHelper 17 | { 18 | // The Client ID is used by the application to uniquely identify itself to the v2.0 authentication endpoint. 19 | static string clientId = App.Current.Resources["ida:ClientID"].ToString(); 20 | public static string[] Scopes = { "User.Read", "Mail.Send", "Files.ReadWrite" }; 21 | 22 | public static PublicClientApplication IdentityClientApp = new PublicClientApplication(clientId); 23 | 24 | public static string TokenForUser = null; 25 | public static DateTimeOffset Expiration; 26 | public static ApplicationDataContainer _settings = ApplicationData.Current.RoamingSettings; 27 | 28 | /// 29 | /// Get Token for User. 30 | /// 31 | /// Token for user. 32 | public static async Task GetTokenForUserAsync() 33 | { 34 | AuthenticationResult authResult; 35 | try 36 | { 37 | authResult = await IdentityClientApp.AcquireTokenSilentAsync(Scopes, IdentityClientApp.Users.First()); 38 | TokenForUser = authResult.AccessToken; 39 | // save user ID in local storage 40 | _settings.Values["userEmail"] = authResult.User.DisplayableId; 41 | _settings.Values["userName"] = authResult.User.Name; 42 | } 43 | 44 | catch (Exception) 45 | { 46 | if (TokenForUser == null || Expiration <= DateTimeOffset.UtcNow.AddMinutes(5)) 47 | { 48 | authResult = await IdentityClientApp.AcquireTokenAsync(Scopes); 49 | 50 | TokenForUser = authResult.AccessToken; 51 | Expiration = authResult.ExpiresOn; 52 | 53 | // save user ID in local storage 54 | _settings.Values["userEmail"] = authResult.User.DisplayableId; 55 | _settings.Values["userName"] = authResult.User.Name; 56 | } 57 | } 58 | 59 | return TokenForUser; 60 | } 61 | 62 | /// 63 | /// Signs the user out of the service. 64 | /// 65 | public static void SignOut() 66 | { 67 | foreach (var user in IdentityClientApp.Users) 68 | { 69 | IdentityClientApp.Remove(user); 70 | } 71 | 72 | TokenForUser = null; 73 | 74 | //Clear stored values from last authentication. 75 | _settings.Values["userID"] = null; 76 | _settings.Values["userEmail"] = null; 77 | _settings.Values["userName"] = null; 78 | 79 | } 80 | 81 | } 82 | } 83 | 84 | //********************************************************* 85 | // 86 | //O365-UWP-Microsoft-Graph-Connect, https://github.com/OfficeDev/O365-UWP-Microsoft-Graph-Connect 87 | // 88 | //Copyright (c) Microsoft Corporation 89 | //All rights reserved. 90 | // 91 | // MIT License: 92 | // Permission is hereby granted, free of charge, to any person obtaining 93 | // a copy of this software and associated documentation files (the 94 | // ""Software""), to deal in the Software without restriction, including 95 | // without limitation the rights to use, copy, modify, merge, publish, 96 | // distribute, sublicense, and/or sell copies of the Software, and to 97 | // permit persons to whom the Software is furnished to do so, subject to 98 | // the following conditions: 99 | 100 | // The above copyright notice and this permission notice shall be 101 | // included in all copies or substantial portions of the Software. 102 | 103 | // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, 104 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 105 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 106 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 107 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 108 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 109 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 110 | // 111 | //********************************************************* -------------------------------------------------------------------------------- /O365-UWP-Unified-API-Connect/MailHelper.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 2 | 3 | using Newtonsoft.Json.Linq; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.IO; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | using System.Net.Http; 11 | using Windows.Storage; 12 | 13 | namespace O365_UWP_Unified_API_Connect 14 | { 15 | class MailHelper 16 | { 17 | 18 | /// 19 | /// Compose and send a new email. 20 | /// 21 | /// The subject line of the email. 22 | /// The body of the email. 23 | /// A semicolon-separated list of email addresses. 24 | /// 25 | internal async Task ComposeAndSendMailAsync(string subject, 26 | string bodyContent, 27 | string recipients) 28 | { 29 | 30 | // Get current user photo 31 | Stream photoStream = await GetCurrentUserPhotoStreamAsync(); 32 | 33 | 34 | // If the user doesn't have a photo, or if the user account is MSA, we use a default photo 35 | 36 | if (photoStream == null) 37 | { 38 | StorageFile file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync("test.jpg"); 39 | photoStream = (await file.OpenReadAsync()).AsStreamForRead(); 40 | } 41 | 42 | MemoryStream photoStreamMS = new MemoryStream(); 43 | // Copy stream to MemoryStream object so that it can be converted to byte array. 44 | photoStream.CopyTo(photoStreamMS); 45 | byte[] photoStreamBytes = photoStreamMS.ToArray(); 46 | string photoStreamBase64 = Convert.ToBase64String(photoStreamBytes); 47 | 48 | string photoFileId = await UploadFileToOneDriveAsync(photoStreamMS.ToArray()); 49 | 50 | string attachments = "{'contentBytes':'" + photoStreamBase64 + "'," 51 | + "'@odata.type' : '#microsoft.graph.fileAttachment'," 52 | + "'contentType':'image/png'," 53 | + "'name':'me.png'}"; 54 | 55 | // Get the sharing link and insert it into the message body. 56 | string sharingLinkUrl = await GetSharingLinkAsync(photoFileId); 57 | string bodyContentWithSharingLink = String.Format(bodyContent, sharingLinkUrl); 58 | 59 | // Prepare the recipient list 60 | string[] splitter = { ";" }; 61 | var splitRecipientsString = recipients.Split(splitter, StringSplitOptions.RemoveEmptyEntries); 62 | string recipientsJSON = null; 63 | 64 | int n = 0; 65 | foreach (string recipient in splitRecipientsString) 66 | { 67 | if ( n==0) 68 | recipientsJSON += "{'EmailAddress':{'Address':'" + recipient.Trim() + "'}}"; 69 | else 70 | { 71 | recipientsJSON += ", {'EmailAddress':{'Address':'" + recipient.Trim() + "'}}"; 72 | } 73 | n++; 74 | } 75 | 76 | try 77 | { 78 | 79 | HttpClient client = new HttpClient(); 80 | var token = await AuthenticationHelper.GetTokenForUserAsync(); 81 | client.DefaultRequestHeaders.Add("Authorization", "Bearer " + token); 82 | 83 | // Build contents of post body and convert to StringContent object. 84 | // Using line breaks for readability. 85 | string postBody = "{'Message':{" 86 | + "'Body':{ " 87 | + "'Content': '" + bodyContentWithSharingLink + "'," 88 | + "'ContentType':'HTML'}," 89 | + "'Subject':'" + subject + "'," 90 | + "'ToRecipients':[" + recipientsJSON + "]," 91 | + "'Attachments':[" + attachments + "]}," 92 | + "'SaveToSentItems':true}"; 93 | 94 | var emailBody = new StringContent(postBody, System.Text.Encoding.UTF8, "application/json"); 95 | 96 | HttpResponseMessage response = await client.PostAsync(new Uri("https://graph.microsoft.com/v1.0/me/microsoft.graph.SendMail"), emailBody); 97 | 98 | if ( !response.IsSuccessStatusCode) 99 | { 100 | 101 | throw new Exception("We could not send the message: " + response.StatusCode.ToString()); 102 | } 103 | 104 | 105 | } 106 | 107 | catch (Exception e) 108 | { 109 | throw new Exception("We could not send the message: " + e.Message); 110 | } 111 | } 112 | 113 | // Gets the stream content of the signed-in user's photo. 114 | // This snippet doesn't work with consumer accounts. 115 | public async Task GetCurrentUserPhotoStreamAsync() 116 | { 117 | Stream currentUserPhotoStream = null; 118 | 119 | try 120 | { 121 | HttpClient client = new HttpClient(); 122 | var token = await AuthenticationHelper.GetTokenForUserAsync(); 123 | client.DefaultRequestHeaders.Add("Authorization", "Bearer " + token); 124 | 125 | // Endpoint for the current user's photo 126 | Uri photoEndpoint = new Uri("https://graph.microsoft.com/v1.0/me/photo/$value"); 127 | 128 | HttpResponseMessage response = await client.GetAsync(photoEndpoint); 129 | 130 | if (response.IsSuccessStatusCode) 131 | { 132 | currentUserPhotoStream = await response.Content.ReadAsStreamAsync(); 133 | } 134 | 135 | else 136 | { 137 | return null; 138 | } 139 | 140 | } 141 | 142 | 143 | catch (Exception e) 144 | { 145 | return null; 146 | 147 | } 148 | 149 | return currentUserPhotoStream; 150 | 151 | } 152 | 153 | // Uploads the specified file to the user's root OneDrive directory. 154 | public async Task UploadFileToOneDriveAsync(byte[] file) 155 | { 156 | string uploadedFileId = null; 157 | JObject jResult = null; 158 | 159 | try 160 | { 161 | 162 | HttpClient client = new HttpClient(); 163 | var token = await AuthenticationHelper.GetTokenForUserAsync(); 164 | client.DefaultRequestHeaders.Add("Authorization", "Bearer " + token); 165 | 166 | MemoryStream fileStream = new MemoryStream(file); 167 | var fileContentPostBody = new StreamContent(fileStream); 168 | 169 | // Endpoint for content in an existing file. 170 | Uri fileEndpoint = new Uri("https://graph.microsoft.com/v1.0/me/drive/root/children/me.png/content"); 171 | 172 | var requestMessage = new HttpRequestMessage(HttpMethod.Put, fileEndpoint) 173 | { 174 | Content = fileContentPostBody 175 | }; 176 | 177 | 178 | HttpResponseMessage response = await client.SendAsync(requestMessage); 179 | 180 | if (response.IsSuccessStatusCode) 181 | { 182 | string responseContent = await response.Content.ReadAsStringAsync(); 183 | jResult = JObject.Parse(responseContent); 184 | uploadedFileId = (string)jResult["id"]; 185 | 186 | 187 | } 188 | 189 | return uploadedFileId; 190 | } 191 | 192 | catch (Exception e) 193 | { 194 | throw new Exception("We could not create the file. The request returned this status code: " + e.Message); 195 | } 196 | } 197 | 198 | public static async Task GetSharingLinkAsync(string Id) 199 | { 200 | string sharingLinkUrl = null; 201 | JObject jResult = null; 202 | 203 | try 204 | { 205 | HttpClient client = new HttpClient(); 206 | var token = await AuthenticationHelper.GetTokenForUserAsync(); 207 | client.DefaultRequestHeaders.Add("Authorization", "Bearer " + token); 208 | 209 | string postContent = "{'type': 'view','scope': 'anonymous'}"; 210 | var createBody = new StringContent(postContent, System.Text.Encoding.UTF8, "application/json"); 211 | Uri photoEndpoint = new Uri("https://graph.microsoft.com/v1.0/me/drive/items/" + Id + "/createLink"); 212 | HttpResponseMessage response = await client.PostAsync(photoEndpoint, createBody); 213 | if (response.IsSuccessStatusCode) 214 | { 215 | string responseContent = await response.Content.ReadAsStringAsync(); 216 | jResult = JObject.Parse(responseContent); 217 | JToken sharingLink = jResult["link"]; 218 | sharingLinkUrl = (string)sharingLink["webUrl"]; 219 | 220 | } 221 | else 222 | { 223 | return null; 224 | } 225 | 226 | } 227 | 228 | catch (Exception e) 229 | { 230 | throw new Exception("We could not get the sharing link. The request returned this status code: " + e.Message); 231 | } 232 | 233 | return sharingLinkUrl; 234 | } 235 | } 236 | } 237 | //********************************************************* 238 | // 239 | //O365-UWP-Microsoft-Graph-Connect, https://github.com/OfficeDev/O365-UWP-Microsoft-Graph-Connect 240 | // 241 | //Copyright (c) Microsoft Corporation 242 | //All rights reserved. 243 | // 244 | // MIT License: 245 | // Permission is hereby granted, free of charge, to any person obtaining 246 | // a copy of this software and associated documentation files (the 247 | // ""Software""), to deal in the Software without restriction, including 248 | // without limitation the rights to use, copy, modify, merge, publish, 249 | // distribute, sublicense, and/or sell copies of the Software, and to 250 | // permit persons to whom the Software is furnished to do so, subject to 251 | // the following conditions: 252 | 253 | // The above copyright notice and this permission notice shall be 254 | // included in all copies or substantial portions of the Software. 255 | 256 | // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, 257 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 258 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 259 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 260 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 261 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 262 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 263 | // 264 | //********************************************************* -------------------------------------------------------------------------------- /O365-UWP-Unified-API-Connect/MainPage.xaml: -------------------------------------------------------------------------------- 1 |  2 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |