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

omniauth: (microsoft_graph_auth) Authentication failure! invalid_credentials: OAuth2::Error

VedaRamaiah opened this issue · comments

I followed all the steps, created the same app on Azure B2C portal as well. I am able to authenticate with the credentails but throwing the error (omniauth: (microsoft_graph_auth) Authentication failure! invalid_credentials: OAuth2::Error) during callback.

-23 23:20:23 -0500
I, [2020-11-23T23:20:23.472229 #8624] INFO -- omniauth: (microsoft_graph_auth) Callback phase initiated.
E, [2020-11-23T23:20:24.336261 #8624] ERROR -- omniauth: (microsoft_graph_auth) Authentication failure! invalid_credentials: OAuth2::Error

{"id_token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6Ilg1ZVhrNHh5b2pORnVtMWtsMll0djhkbE5QNC1jNTdkTzZRR1RWQndhTmsifQ.eyJleHAiOjE2MDYxOTU1NDEsIm5iZiI6MTYwNjE5MTk0MSwidmVyIjoiMS4wIiwiaXNzIjoiaHR0cHM6Ly9pbmZseXR4cGQuYjJjbG9naW4uY29tL2I3ZDNhZTc4LTA4NjItNGJlYS05ZmYxLWZmMWI1MDM1MmJjNi92Mi4wLyIsInN1YiI6IjI3ZmQ5MTkxLTAwOWEtNDMzZi1hN2ZmLTZmNjVkM2ZlNDk5ZCIsImF1ZCI6ImM3ZGZkZDBiLTE1NDAtNDE3ZS1iNTdlLWZhMjRjNDIxOGM0MyIsImlhdCI6MTYwNjE5MTk0MSwiYXV0aF90aW1lIjoxNjA2MTkxOTQwLCJvaWQiOiIyN2ZkOTE5MS0wMDlhLTQzM2YtYTdmZi02ZjY1ZDNmZTQ5OWQiLCJuYW1lIjoiVmVkYS5SYW1haWFoQGx0dHMuY29tIiwiZW1haWxzIjpbIlZlZGEuUmFtYWlhaEBsdHRzLmNvbSJdLCJ0ZnAiOiJCMkNfMV9TSUdOX0lOIn0.o04QC811sXkRFHIgUEbW5CrH4ed4t2bKjqWc8koENY6xyb3JHzde2NAMOQoKJ2S-jRT91AIczLJQW1gB7RXqcqyX5wQRpbSxGIXPAr1hvXQ9W1zdwvkDVM9U99NIGREviHnuRJXLOXjxyWtglIldYjPyGPidhZpoc6cNpuYdZGb-ISGZmS8W-7fKzjMHS6okg_IB--nuVISXbEEzlU782tMFyySq9eh8bnrzc8ZRUaeZk3dJqsFPB1tVT74CZ65GBkBFAzefU1wz_1P8L6ZkhNLRl42WhWeUJFgtSKGRNtiF5cRMnlE6PCIoCXsVUMEG_BFVoHSHW6kmyjfIXSXbOw","token_type":"Bearer","not_before":1606191941,"id_token_expires_in":3600,"profile_info":"eyJ2ZXIiOiIxLjAiLCJ0aWQiOiJiN2QzYWU3OC0wODYyLTRiZWEtOWZmMS1mZjFiNTAzNTJiYzYiLCJzdWIiOm51bGwsIm5hbWUiOiJWZWRhLlJhbWFpYWhAbHR0cy5jb20iLCJwcmVmZXJyZWRfdXNlcm5hbWUiOm51bGwsImlkcCI6bnVsbH0","scope":"offline_access openid","refresh_token":"eyJraWQiOiJjcGltY29yZV8wOTI1MjAxNSIsInZlciI6IjEuMCIsInppcCI6IkRlZmxhdGUiLCJzZXIiOiIxLjAifQ..Brt-lzu9a5LTUUFw.fpKmOJFKfWu77gnmDx4dH0fUv0fCRL__60BKfYjXFPT3u2bR7BjMcy_1Gi7S_3NVUFN7tFR92S9soFdGpyPFYXAZAWd-K_3NUJ_YCkFcoOlRJVsyr-sLHy7DYYAzqpPyaC5dOQ9H7WSkPRmfmXZjCZxMTrGFJvPVDxEkLfd600i9i578DdogmO-4704gm0aI3qAPHqxzRQex1A8Y1ZxsWwNlySd0rBnVHpnMtPC1ZMbxnYpit86sRRQN5iHcvWQ7VizvzzTem9VGJyechH5tIeZv2waGjFkpRnY65XT84uJMm1a-Z6ugqkT33O7CC1RqEnq_xhnB8szauqBBEV6h5PD1qadrLvghep4hZPMQoVwEyK19Ajq6g96RCrncPkMFuO4bKQrLmsbzSp46p-vlX6kRgb0cAbl8Mc8BWty4vF9zJ8ZUqdKiJ20-9W7Q3pUMW0lah2fehE37gIe2gxKm2_Sncc3emduidCQhRVvbJGqHCVYKGqHhxwOTqsWsYE2EGxopi0H2oii1RD0c91I9firvvw47kvEmAdTIU5hz9_54Lcqz4OuieWF6Oi8Qvj7J-54zuQ.u4R_4EhbDLqGWLtGwx-vUw","refresh_token_expires_in":1209600}

Application Trace | Framework Trace | Full Trace
oauth2 (1.4.4) lib/oauth2/client.rb:150:in get_token' oauth2 (1.4.4) lib/oauth2/strategy/auth_code.rb:30:in get_token'
omniauth-oauth2 (1.7.0) lib/omniauth/strategies/oauth2.rb:126:in build_access_token' omniauth-oauth2 (1.7.0) lib/omniauth/strategies/oauth2.rb:91:in callback_phase'
omniauth (1.9.1) lib/omniauth/strategy.rb:238:in callback_call' omniauth (1.9.1) lib/omniauth/strategy.rb:189:in call!'
omniauth (1.9.1) lib/omniauth/strategy.rb:169:in call' omniauth (1.9.1) lib/omniauth/builder.rb:45:in call'

Execption been thrown at callback method in omniauth. I tried all ways but none of them worked.

Can you please let me know how to resolve this issue?

Are you authenticating as a B2C user? B2C users cannot get tokens for Microsoft Graph. In B2C tenants, Microsoft Graph is limited to user admins for management scenarios. See https://docs.microsoft.com/azure/active-directory-b2c/microsoft-graph-operations

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.

Whats the best way to tweak/go ahead for B2C tenants?