无法更改UWP示例Microsoft Graph中的范围 [英] Unable to Change Scopes in UWP Sample Microsoft Graph

查看:64
本文介绍了无法更改UWP示例Microsoft Graph中的范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下UWP示例: https://github.com/microsoftgraph/msgraph- training-uwp 它演示了Microsoft Graph,这是一项允许用户使用其Microsoft帐户登录应用程序的服务,以便该应用程序可以访问用户授予的数据.默认情况下,该示例请求calandar的范围,以查看calandar数据,但是我想编辑该示例以访问用户的范围.这是因为我的应用程序用于购买应用程序,并且位于公共计算机上,所以我希望用户的操作与他们的帐户绑定. 但是,每当我尝试更改示例范围时,该应用程序均无法正常运行,否则会崩溃.有什么我想念的吗?还是有什么方法可以改变范围?

I am using this UWP sample: https://github.com/microsoftgraph/msgraph-training-uwp It demonstrates Microsoft Graph, A service for allowing useres to login to apps with their microsoft account so that the app can access the users granted data. By default, the sample requests the calandar's scope, to veiw calandar data, but I would like to edit the sample to access the scope of the user. This is because my app uses in app purchases, and is on a public machine, and I want what users do to be tied to their accounts. However whenever I try to change the scope of the sample, the app doesnt work correctly, or it crashes. Is there something I'm missing? or is there some way to change the scope?

推荐答案

您可以在portal.azure.com的应用程序注册中将User.Read范围添加到您的应用程序.下次您运行该应用并登录时,它会要求您同意此新权限.

You can add User.Read scope to your application in the app registration in portal.azure.com. Next time you run the app and sign in , it should ask you to consent this new permission.

然后在代码中,可以将其更改为调用/me而不是/me/events.它将返回用户配置文件数据,如图形资源管理器"中此处所示

Then in your code you can change it to call /me rather than /me/events. It will return the users profile data like shown in Graph Explorer here https://developer.microsoft.com/en-us/graph/graph-explorer?request=me/&method=GET&version=v1.0&GraphUrl=https://graph.microsoft.com

本教程也更容易在这里进行遵循 https://docs.microsoft .com/en-us/graph/tutorials/uwp

The tutorial is also easier to follow here https://docs.microsoft.com/en-us/graph/tutorials/uwp

这篇关于无法更改UWP示例Microsoft Graph中的范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆