Git Product home page Git Product logo

omniauth-office365's Introduction

OmniAuth Office365

Gem Version Build Status Code Climate

Gem to authenticate applications to the Office365 v2.0 REST API via OAuth2.

Note An unmaintained (at least as of this writing) omniauth-office365 gem exists at https://github.com/simi/omniauth-office365. However, it's built on an older, deprecated version of the API.

Setup

Note Depending on the which scopes you choose, a successful response may not contain an access_token. In that cases, an error will be raised in the oauth2 gem. There's a PR that should address this: oauth-xx/oauth2#243.

Standard setup:

  # Add to your initializers/omniauth.rb

  use OmniAuth::Builder do
    provider :office365, ENV['OFFICE365_APP_ID'], ENV['OFFICE365_APP_SECRET'], :scope => 'https://outlook.office.com/mail.read'
  end

Setup with Devise:

  # Add to your devise.rb

  config.omniauth :office365, ENV['OFFICE365_APP_ID'], ENV['OFFICE365_APP_SECRET'], :scope => 'https://outlook.office.com/mail.read'

omniauth-office365's People

Contributors

jeffcarbs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

omniauth-office365's Issues

OAuth2::Error, invalid_client: AADSTS70002: Error validating credentials.

Hi there, I'm attempting to use your gem to grab oauth2 credentials from Microsoft to access Outlook. I keep receiving this error chain (here's the output from my log):

Started GET "/auth/office365" for 76.21.4.108 at 2017-03-28 19:39:58 +0000
(office365) Request phase initiated.


Started GET "/auth/office365/callback?code=AQABAAIAAABnfiG-mA6NTae7CdWW7QfdzytQ0_8r1J-iqN6ssQ5rwhfSlo6A98_D1iOtONxSjbooyTppxMGORbhbaXR5L4fDjopDFjuNcgUNYQgXvfyTyvtNLAYNEwOJQVgEwDc0NBWTTO58a6XdafGcJg9_RlE0RJ5f2BRpRGUWZqeFuOjUSJZPpOSF2CaDK1Sol7xCsolyyBQmpqGci4e8TvvPCVz66nkiMUC1BbOeMQ0Als0B7Ul5A6XY3_FXieMMtFaIihAmGRGSwBFgscnQyopI5diO_yTSGACr81n9KTONdDxANRa_UPDVfj4UhNgVGcgk4H0nbtRjEcSzhr3HmiBhCdx-XaOO8mkBbDXV-UCCOM9xCzk80HV8FohaP5-IQJDrAexWnYJRPVinqXYvm_UVaZhGNkMd_uQsGL839gyzGefRqE38pIBLLB1ybfdvj1vcnypo-R8rG8H9k36RzxryiTPADXafPONxqXIkCKyFHruY_V4TqQRdNFZ9_iOG11mmkgoS4rrMHXAZkyaNQffOy63kJ3igFIUyrfWrKmxPTD_JxRT5V37IlTEB5cuFsYBQiX4gAA&state=de31e16017276349b98454837d009a151e63af27e74f51a3&session_state=0a9aa0a0-bc11-4f13-b8c6-4130d81514d3" for 76.21.4.108 at 2017-03-28 19:40:06 +0000
(office365) Callback phase initiated.
(office365) Authentication failure! invalid_credentials: OAuth2::Error, invalid_client: AADSTS70002: Error validating credentials. AADSTS50011: The reply address 'https://dev.example.com/auth/office365/callback?code=AQABAAIAAABnfiG-mA6NTae7CdWW7QfdzytQ0_8r1J-iqN6ssQ5rwhfSlo6A98_D1iOtONxSjbooyTppxMGORbhbaXR5L4fDjopDFjuNcgUNYQgXvfyTyvtNLAYNEwOJQVgEwDc0NBWTTO58a6XdafGcJg9_RlE0RJ5f2BRpRGUWZqeFuOjUSJZPpOSF2CaDK1Sol7xCsolyyBQmpqGci4e8TvvPCVz66nkiMUC1BbOeMQ0Als0B7Ul5A6XY3_FXieMMtFaIihAmGRGSwBFgscnQyopI5diO_yTSGACr81n9KTONdDxANRa_UPDVfj4UhNgVGcgk4H0nbtRjEcSzhr3HmiBhCdx-XaOO8mkBbDXV-UCCOM9xCzk80HV8FohaP5-IQJDrAexWnYJRPVinqXYvm_UVaZhGNkMd_uQsGL839gyzGefRqE38pIBLLB1ybfdvj1vcnypo-R8rG8H9k36RzxryiTPADXafPONxqXIkCKyFHruY_V4TqQRdNFZ9_iOG11mmkgoS4rrMHXAZkyaNQffOy63kJ3igFIUyrfWrKmxPTD_JxRT5V37IlTEB5cuFsYBQiX4gAA&state=de31e16017276349b98454837d009a151e63af27e74f51a3&session_state=0a9aa0a0-bc11-4f13-b8c6-4130d81514d3' does not match the reply address 'https://dev.example.com/auth/office365/callback' provided when requesting Authorization code.
Trace ID: 154ea3f3-9f24-4599-a7c9-e3f29c6a3800
Correlation ID: 42bf9100-12a7-4510-b5a2-52f084d5321c
Timestamp: 2017-03-28 19:39:13Z
{"error":"invalid_client","error_description":"AADSTS70002: Error validating credentials. AADSTS50011: The reply address 'https://dev.example.com/auth/office365/callback?code=AQABAAIAAABnfiG-mA6NTae7CdWW7QfdzytQ0_8r1J-iqN6ssQ5rwhfSlo6A98_D1iOtONxSjbooyTppxMGORbhbaXR5L4fDjopDFjuNcgUNYQgXvfyTyvtNLAYNEwOJQVgEwDc0NBWTTO58a6XdafGcJg9_RlE0RJ5f2BRpRGUWZqeFuOjUSJZPpOSF2CaDK1Sol7xCsolyyBQmpqGci4e8TvvPCVz66nkiMUC1BbOeMQ0Als0B7Ul5A6XY3_FXieMMtFaIihAmGRGSwBFgscnQyopI5diO_yTSGACr81n9KTONdDxANRa_UPDVfj4UhNgVGcgk4H0nbtRjEcSzhr3HmiBhCdx-XaOO8mkBbDXV-UCCOM9xCzk80HV8FohaP5-IQJDrAexWnYJRPVinqXYvm_UVaZhGNkMd_uQsGL839gyzGefRqE38pIBLLB1ybfdvj1vcnypo-R8rG8H9k36RzxryiTPADXafPONxqXIkCKyFHruY_V4TqQRdNFZ9_iOG11mmkgoS4rrMHXAZkyaNQffOy63kJ3igFIUyrfWrKmxPTD_JxRT5V37IlTEB5cuFsYBQiX4gAA&state=de31e16017276349b98454837d009a151e63af27e74f51a3&session_state=0a9aa0a0-bc11-4f13-b8c6-4130d81514d3' does not match the reply address 'https://dev.example.com/auth/office365/callback' provided when requesting Authorization code.\r\nTrace ID: 154ea3f3-9f24-4599-a7c9-e3f29c6a3800\r\nCorrelation ID: 42bf9100-12a7-4510-b5a2-52f084d5321c\r\nTimestamp: 2017-03-28 19:39:13Z","error_codes":[70002,50011],"timestamp":"2017-03-28 19:39:13Z","trace_id":"154ea3f3-9f24-4599-a7c9-e3f29c6a3800","correlation_id":"42bf9100-12a7-4510-b5a2-52f084d5321c"}
Processing by AuthController#failure as HTML
  Parameters: {"code"=>"AQABAAIAAABnfiG-mA6NTae7CdWW7QfdzytQ0_8r1J-iqN6ssQ5rwhfSlo6A98_D1iOtONxSjbooyTppxMGORbhbaXR5L4fDjopDFjuNcgUNYQgXvfyTyvtNLAYNEwOJQVgEwDc0NBWTTO58a6XdafGcJg9_RlE0RJ5f2BRpRGUWZqeFuOjUSJZPpOSF2CaDK1Sol7xCsolyyBQmpqGci4e8TvvPCVz66nkiMUC1BbOeMQ0Als0B7Ul5A6XY3_FXieMMtFaIihAmGRGSwBFgscnQyopI5diO_yTSGACr81n9KTONdDxANRa_UPDVfj4UhNgVGcgk4H0nbtRjEcSzhr3HmiBhCdx-XaOO8mkBbDXV-UCCOM9xCzk80HV8FohaP5-IQJDrAexWnYJRPVinqXYvm_UVaZhGNkMd_uQsGL839gyzGefRqE38pIBLLB1ybfdvj1vcnypo-R8rG8H9k36RzxryiTPADXafPONxqXIkCKyFHruY_V4TqQRdNFZ9_iOG11mmkgoS4rrMHXAZkyaNQffOy63kJ3igFIUyrfWrKmxPTD_JxRT5V37IlTEB5cuFsYBQiX4gAA", "state"=>"de31e16017276349b98454837d009a151e63af27e74f51a3", "session_state"=>"0a9aa0a0-bc11-4f13-b8c6-4130d81514d3"}
Completed 400 Bad Request in 5ms (Views: 4.3ms | ActiveRecord: 0.0ms)

In my omniauth initializer, I have:

provider :office365, <<APP_ID>>, <<APP_SECRET>>, scope: "https://outlook.office.com/mail.read offline_access"

The redirect URI I've specified on apps.dev.microsoft.com is https://dev.example.com/auth/office365/callback (with my own domain in place of example.com). I've successfully done this same thing with Google, Salesforce, Twitter, and a bunch more, and I'm wondering if this is due to your gem or something else. Ever run into this before?

Including multiple scopes

How do I go about including multiple scopes? If I include any more than one I get AADSTS70011: The provided value for the input parameter 'scope' is not valid. The scope Contacts.Read, Mail.Read is not valid..

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.