Coder Social home page Coder Social logo

microsoftgraph / msgraph-sample-uwp Goto Github PK

View Code? Open in Web Editor NEW
31.0 8.0 13.0 16.41 MB

This sample demonstrates how to use the Microsoft Graph .NET SDK to access data in Office 365 from UWP apps.

License: MIT License

C# 100.00%
microsoft-graph uwp devxsample

msgraph-sample-uwp's Introduction

page_type description products languages
sample
This sample demonstrates how to use the Microsoft Graph .NET SDK to access data in Office 365 from UWP apps.
ms-graph
office-exchange-online
csharp
dotnet

Microsoft Graph sample UWP app

MSBuild License.

This sample demonstrates how to use the Microsoft Graph .NET SDK to access data in Office 365 from UWP apps.

Prerequisites

To run the completed project in this folder, you need the following:

  • Visual Studio installed on your development machine. If you do not have Visual Studio, visit the previous link for download options. (Note: This tutorial was written with Visual Studio 2022 version 17.3.5. The steps in this guide may work with other versions, but that has not been tested.)
  • Either a personal Microsoft account with a mailbox on Outlook.com, or a Microsoft work or school account.

If you don't have a Microsoft account, there are a couple of options to get a free account:

Register a native application with the Azure Active Directory admin center

  1. Open a browser and navigate to the Azure Active Directory admin center and login using a personal account (aka: Microsoft Account) or Work or School Account.

  2. Select Azure Active Directory in the left-hand navigation, then select App registrations under Manage.

  3. Select New registration. On the Register an application page, set the values as follows.

    • Set Name to UWP Graph Sample.
    • Set Supported account types to Accounts in any organizational directory and personal Microsoft accounts.
    • Under Redirect URI, change the dropdown to Public client (mobile & desktop), and set the value to https://login.microsoftonline.com/common/oauth2/nativeclient.
  4. Choose Register. On the UWP Graph Tutorial page, copy the value of the Application (client) ID and save it, you will need it in the next step.

Configure the sample

  1. Rename the OAuth.resw.example file to OAuth.resw.
  2. Open graph-tutorial.sln in Visual Studio.
  3. Edit the OAuth.resw file in visual studio. Replace YOUR_APP_ID_HERE with the Application Id you got from the App Registration Portal.
  4. In Solution Explorer, right-click the graph-tutorial solution and choose Restore NuGet Packages.

Run the sample

In Visual Studio, press F5 or choose Debug > Start Debugging.

Code of conduct

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.

Disclaimer

THIS CODE IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.

msgraph-sample-uwp's People

Contributors

andrewconnell avatar baywet avatar dependabot[bot] avatar dodaromike avatar github-actions[bot] avatar jasonjoh avatar jthake avatar juliemturner avatar microsoft-github-policy-service[bot] avatar sbovo avatar yinaa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

msgraph-sample-uwp's Issues

The name 'AttendeePicker' does not exist in the current context GraphTutorial

Where did you get the code?

Describe the bug
Build error:
Severity Code Description Project File Line Suppression State
Error CS0103 The name 'AttendeePicker' does not exist in the current context GraphTutorial D:\test\other\Graph\msgraph-training-uwp-main\demo\GraphTutorial\NewEventPage.xaml.cs 237 Active

To Reproduce
Steps to reproduce the behavior:
Build the downloaded solution.

Expected behavior
Build without error.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Windows 11
  • Browser N/A
  • Version N/A

Dependency versions

  • Authentication library (MSAL, etc.) version:
  • Graph library (Graph SDK, REST library, etc.) version:

Additional context
Add any other context about the problem here.

Only works with 1 scope?

I got the sample working, but I wanted to change scopes to suite the app I am making. It works with Calendar.Read, but with no other scopes. How could I edit this sample so that It doesnt hang/ crash with other scopes?

Unhandled exception when login window is closed

I noticed that the demo solutions crash if I close the login window with the title bar close button. The exception message says:

"User canceled authentication. On an Android device, this could be due to the lack of capabilities, such as custom tabs, for the system browser. See https://aka.ms/msal-net-system-browsers for more information."

Please advice how to catch this exception? I already tried to subscribe to the MicrosoftGraphService.Instance.SignInFailed event but it doesn't fire in this situation.

Instructions appear to be out of date or inaccurate.

While trying to follow the instructions for registering the UWP app samples, I was not able to determine how I might add the redirect URI of: urn:ietf:wg:oauth:2.0:oob

Here are the steps I followed (visually):

image

When trying to set the redirect uri I see this:

image

What am I missing. How do I set the urn:ietf:wg:oauth:2.0:oob ???

PeoplePicker control of Microsoft.Toolkit.Graph.Controls Asking for singing again if already & Sing out automatically after adding new event

Where did you get the code?

Describe the bug
After sign in into the given demo application, I was trying to add new event. It is asking for sign in again when I try to search event Attendee by their name in PeoplePicker control.

To Reproduce
Steps to reproduce the behavior:
Issue 1:
1. Open the application from visual studio
2. sign in into the application & go to the NewEvent Page
3. Try to search by name in Attendee Textbox(PeoplePicker control) : Use name of already sign in user
4. After sign in again from sign in window, sign in window will not close. you need to close manually.
5. Create event & after creating it will sign out you from application
6. go to the Calendar page, it will ask for sign in again

Issue 2:
1. Open the application from visual studio
2. sign in into the application & go to the NewEvent Page
3. Try to search by name in Attendee Textbox(PeoplePicker control) : Use different name of user by which you are not sign in
4. After sign in again from sign in window, sign in window will hang.
5. go to the Calendar page, it will ask for sign in again

Expected behavior

  1. After sign in into the application, user try to search user by their name in Attendee Textbox(PeoplePicker control), I should not ask for sign in again.
  2. If user try to search by different user name, sign in window should not hang

Screenshots
After search user by different name than already sign in, the app just hangs indefinitely and a little blue flashing dot appears in the upper left hand corner. (See attached image for issue 2)
image

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser: N/A
  • Version: N/A

Dependency versions

  • Authentication library (MSAL, etc.) version:
  • Graph library (Graph SDK, REST library, etc.) version:

Additional context
Visual studio 22

Missing Type: AttendeePicker

Where did you get the code?
Downloaded and followed instructions.

Describe the bug
Type AttendeePicker is not found.

To Reproduce
Follow the instructions for the tutorial.

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Dependency versions

  • Authentication library (MSAL, etc.) version:
  • Graph library (Graph SDK, REST library, etc.) version:

Additional context
Add any other context about the problem here.

Microsoft Graph does not work currently in UWP

Where did you get the code?
Down load the code

Describe the bug
When compiling there are hundreds of errors specifically related to the Microsoft Graph. The current shipping versions have a dependency on .NET 5.0 and will not compile in UWP.

To Reproduce
Steps to reproduce the behavior:
Follow the instructions in the tutorial.

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Dependency versions

  • Authentication library (MSAL, etc.) version:
  • Graph library (Graph SDK, REST library, etc.) version:

Additional context
Add any other context about the problem here.

Cannot Log-in

I just did what was advised in the sample download, but after I type in my email address, I get:
invalid_request: The provided value for the input parameter 'redirect_uri' is not valid. The expected value is a URI which matches a redirect URI registered for this client application.

I did not change a single line of code, so any idea what went wrong?

Getting Error reading JObject from JsonReader. Current JsonReader item is not an object: String. Path 'userPurpose' in the Demo project.

Where did you get the code?

Describe the bug
Is not possible to get the MailboxSettings with the projects as it is. If you run the project you get a Newtonsoft.Json.JsonReaderException, this happen following the tutorial o downloading the demo project from github, in both cases I have replaced the AppID with my own id.
To Reproduce
Steps to reproduce the behavior (for the demo):

  1. Open the solution
  2. Rename the OAuth.resw.example to OAuth.resw
  3. Added my AppID
  4. Run the app
  5. Login with my account
  6. The app displays my name over the top-right corrner.
  7. Press Calendar.
  8. The exception is displayed.

Expected behavior
I'm expecting to see the calendar as the tutorial and documentation indicates.

Screenshots

Bug Graph

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Dependency versions

  • Authentication library (MSAL, etc.) version:
  • Graph library (Graph SDK, REST library, etc.) version:

Additional context
Exception output:
Newtonsoft.Json.JsonReaderException
HResult=0x80131500
Mensaje = Error reading JObject from JsonReader. Current JsonReader item is not an object: String. Path 'userPurpose', line 1, position 492.
Origen = Newtonsoft.Json
Seguimiento de la pila:
en Newtonsoft.Json.Linq.JObject.Load(JsonReader reader, JsonLoadSettings settings)
en Microsoft.Graph.DerivedTypeConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
en Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
en Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
en Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
en Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Populate(JsonReader reader, Object target)
en Microsoft.Graph.DerivedTypeConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
en Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
en Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
en Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
en Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Populate(JsonReader reader, Object target)
en Microsoft.Graph.DerivedTypeConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
en Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
en Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
en Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
en Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
en Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
en Microsoft.Graph.Serializer.DeserializeObject[T](String inputString)
en Microsoft.Graph.ResponseHandler.d__21.MoveNext() en System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() en System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) en Microsoft.Graph.BaseRequest.<SendAsync>d__341.MoveNext()
en System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
en System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
en Microsoft.Graph.UserRequest.d__6.MoveNext()
en System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
en System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
en System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
en GraphTutorial.CalendarPage.d__2.MoveNext() en C:\Users\Alienware Alpha\source\repos\GraphTutorial\GraphTutorial\CalendarPage.xaml.cs: línea 52

Esta excepción se generó originalmente en esta pila de llamadas:
[Código externo]
GraphTutorial.CalendarPage.OnNavigatedTo(Windows.UI.Xaml.Navigation.NavigationEventArgs) en CalendarPage.xaml.cs

Redirect URI not matching

invalid_request: The provided value for the input parameter 'redirect_uri' is not valid. The expected value is a URI which matches a redirect URI registered for this client application.

WAB Authentication Failed

I'm getting a 'WAB Authentication Failed' message. I'm using my organization account to sign in. I registered my app using the Azure Portal and I'm wondering if that's the problem, but I want to understand why if that's the case.

Cannot sign-in

Using the Quick Start (using UWP), I did all of the steps (register app, got app id, went to the azure portal, added redirect, downloaded the zip, extracted). I loaded the solution and built it (using x64). When I run it there is no "sign-in" button. I watched the video under Build UWP apps with Microsoft Graph, he shows the same app with the button and he can sign in.

Am I missing something? Do I need to go through the tutorial to manually add the underlying code?

UPDATED I went through the step by step guide building the application from scratch and I have the same issue at the end of Step 1. All of the code copied correctly, it builds and executes ... but NO "sign in" button control.

I am building using VS2017 and Win10 Enterprise 1709 Build 16299.1451 ... is this an issue for this application?

PLEASE HELP

How to obtain email information in the msgraph sample uwp demo?

How to obtain email information in the msgraph sample uwp demo? I tried to obtain email information and it appears
Code: ErrorAccessDenied
Message: Access is denied. Check credentials and try again.
The code is as follows:
var events = await graphClient.Me.MailFolders["Inbox"].Messages.Request().GetAsync();

error connection

Hi, iam new on graoh API and UWP

when i would debug my UWP, i get the error:

DEP6957: Failed to connect to device "127.0.0.1" using universal authentication. Please ensure that the correct remote authentication mode is specified in the project's debug settings. COMException - A connection could not be established because the target computer refused to connect. (Exception from HRESULT: 0x8007274D) [0x8007274D] GraphTutorial

Please help

Kind regards

Unable To Login

After entering the Microsoft account, the following error message pops up:
We're unable to complete your request
Microsoft account is experiencing technical problems. Please try again later
(I replace YOUR_APP_ID_HERE with the Application Id I got from the App Registration Portal)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.