问题
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?
回答1:
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.
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
The tutorial is also easier to follow here https://docs.microsoft.com/en-us/graph/tutorials/uwp
来源:https://stackoverflow.com/questions/58108384/unable-to-change-scopes-in-uwp-sample-microsoft-graph