Closed Mohammed-Balfaqih closed 1 year ago
@jasonjoh any idea?
Check if it is a service issue with Graph. Go to https://developer.microsoft.com/en-us/graph/graph-explorer and sign in with that same account, then try running the same query: https://graph.microsoft.com/v1.0/me?$select=displayName,mail,mailboxSettings,userPrincipalName
Just to be sure I tried this just now with my personal Outlook.com account and the call succeeded.
@jasonjoh I tried to call from the: https://developer.microsoft.com/en-us/graph/graph-explorer and the call succeeded as well. so what do you think the issue will be? 🤔
This is the logs if it can help:
OAuth2::AccessToken.from_hash: `hash` contained more than one 'token' key (["access_token", "id_token"]); using "access_token".
Started GET "/auth/microsoft_graph_auth/callback?code=M.R3_BAY.51cfdb67-748b-e3c3-9f23-c286c558ab20&state=72d207ce617bc770ecf66d55ed725ffe2d13f18cb1a3f5da" for ::1 at 2023-02-01 17:07:53 +0300
D, [2023-02-01T17:07:53.859309 #68868] DEBUG -- omniauth: (microsoft_graph_auth) Callback phase initiated.
OAuth2::AccessToken.from_hash: `hash` contained more than one 'token' key (["access_token", "id_token"]); using "access_token".
E, [2023-02-01T17:08:29.384032 #68868] ERROR -- omniauth: (microsoft_graph_auth) Authentication failure! Net::OpenTimeout: OAuth2::ConnectionError, Net::OpenTimeout
OAuth2::ConnectionError (Net::OpenTimeout):
lib/microsoft_graph_auth.rb:39:in `raw_info'
lib/microsoft_graph_auth.rb:32:in `block in <class:MicrosoftGraphAuth>'
E, [2023-02-01T17:08:55.698072 #68868] ERROR -- omniauth: (microsoft_graph_auth) Authentication failure! Net::OpenTimeout: OAuth2::ConnectionError, Net::OpenTimeout
OAuth2::ConnectionError (Net::OpenTimeout):
lib/microsoft_graph_auth.rb:39:in `raw_info'
lib/microsoft_graph_auth.rb:32:in `block in <class:MicrosoftGraphAuth>'
The error seems to indicate a timeout, which would make me think that the request to Graph isn't returning. I've never seen this particular error so I'm not sure what could be causing it. A network trace might help.
Other than that, I'd say check your OAuth config and make sure that's correct. For example, in oauth_environment_variables.rb, check that you have the required scopes in AZURE_SCOPES
:
ENV['AZURE_SCOPES'] = 'openid profile email offline_access user.read mailboxsettings.read calendars.readwrite'
You would need both user.read
and mailboxsettings.read
for that Graph request to succeed.
Ruby version might be relevant as well. I'm using 3.1.2.
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.
after log-in with my Hotmail & password, I'm getting Net::OpenTimeout
it's caused by calling:
@raw_info ||= access_token.get('https://graph.microsoft.com/v1.0/me?$select=displayName,mail,mailboxSettings,userPrincipalName').parsed