microsoftgraph / msgraph-sample-rubyrailsapp

This sample demonstrates how to use the Microsoft Graph REST API to access data in Office 365 from Ruby on Rails apps.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Default "me" url gives errors

frenkel opened this issue · comments

I believe a previous version of this sample project did not include "mailboxSettings" on this line:

@raw_info ||= access_token.get('https://graph.microsoft.com/v1.0/me?$select=displayName,mail,mailboxSettings,userPrincipalName').parsed

Without it my application works out of the box, but with it I get access denied errors. Maybe it should be removed from the sample?

mailboxSettings is needed to get the user's timezone from their mailbox settings. If you're getting access denied, perhaps you haven't consented to MailboxSettings.Read?

I understand. My point is that is not mentioned in the README under "Register a web application", so it seems to me that either the README needs to change, or the mailboxSettings permission needs to be removed from the me-url in order for this sample project to work "out of the box".

None of the permissions are discussed in the README. There is no need to configure the permission on the app registration, the sample does dynamic consent by including the scopes in the authorization request.

The permission should be included in your oauth_environment_variables.rb file:

ENV['AZURE_SCOPES'] = 'openid profile email offline_access user.read mailboxsettings.read calendars.readwrite'

What type of account are you logging into the app with - a work/school account, or a personal Microsoft account (Outlook.com, Hotmail, etc.)?

That's it! I'm missing the , scope: ENV.fetch('AZURE_SCOPES') part. Thank you!
I do think it might be better if the me-request is not done with permissions that are missing from your scope to avoid errors. The default scope is missing mailboxsettings.read, but at least this sample project works without problems.