davidlumley / omniauth-myob Goto Github PK
View Code? Open in Web Editor NEWMYOB authentication strategy for OmniAuth
License: MIT License
MYOB authentication strategy for OmniAuth
License: MIT License
It should redirect to my successful callback endpoint where I can get an access code for API access.
It redirects to a failure callback. The following errors are in the logs:
application_1 | D, [2021-12-06T03:16:20.665570 #1] DEBUG -- omniauth: (myob) Callback phase initiated.
application_1 | E, [2021-12-06T03:16:21.135606 #1] ERROR -- omniauth: (myob) Authentication failure! invalid_credentials: OAuth2::Error, invalid_request:
application_1 | {"error":"invalid_request"}
I am fairly confident that "invalid_credentials" is a red herring here.
It all works fine and I get an access code if I follow the manual example in the myob-api gem. I have other oauth integrations however, so I would prefer not to manually craft this.
My config is fairly straightforward:
Rails.application.config.middleware.use OmniAuth::Builder do
:myob,
ENV['MYOB_API_CONSUMER_KEY'],
ENV['MYOB_API_CONSUMER_SECRET'],
redirect_uri: ENV['MYOB_API_AUTH_CALLBACK_URI']
)
end
The relevant gems I am using are:
oauth2 (1.4.7)
faraday (>= 0.8, < 2.0)
jwt (>= 1.0, < 3.0)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
omniauth (2.0.4)
hashie (>= 3.4.6)
rack (>= 1.6.2, < 3)
rack-protection
omniauth-myob (0.0.2)
omniauth-oauth2 (~> 1.1)
omniauth-oauth2 (1.7.2)
oauth2 (~> 1.4)
omniauth (>= 1.9, < 3)
omniauth-xero-oauth2 (1.0.2)
omniauth (~> 2.0.0)
omniauth-oauth2 (~> 1.7.1)
When attempting to use this strategy, the OAuth flow works well until the callback gets hit.
The uid method fails because raw_info
as loaded by the api is an empty array.
What causes this - or more importantly, what does it mean?
I realised that #3 occurred because the account associated with my MYOB keys has no company files associated. I don't think this is an error (albeit not very useful for me!), but as a developer I have no way of recovering so I can gracefully fail.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.