Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to setup with the package #34

Closed
jarekwg opened this issue Nov 19, 2019 · 6 comments
Closed

Unable to setup with the package #34

jarekwg opened this issue Nov 19, 2019 · 6 comments
Labels

Comments

@jarekwg
Copy link
Member

jarekwg commented Nov 19, 2019

unable to setup with the package. The documentation is not clear
It would be great if you can upload an example just for fetching the company names or something.

Originally posted by @rehmanjaffersayani in #6 (comment)

Hey @rehmanjaffersayani ,
Have you followed the steps in the readme? Where are you up to?

Yeah, I tried. Unable to sort this

InvalidClientIdError: (invalid_request) Invalid client_id parameter value.

I have attached the screenshot for your reference
Screen Shot 2019-11-19 at 11 51 44 am

Can you elaborate what you're doing here:
myob_authorisation_complete_view(cred)

You can't just pass these credentials directly into the view. You have to set up myob_authorisation_complete_view (or similar) as an endpoint that will receive the auth response from MYOB, then redirect user to MYOB where they authenticate themselves and approve the integration. Then MYOB will redirect to your designated callback_uri, where your view will be waiting to handle the request.

I called the same method as defined.
myob_authorisation_complete_view()

I am trying to do in a cron job so I am having issues. Is there any implementation for just starting the process or example.

It would be great

I have run MYOB pre-defined postman and it's working fine

@jarekwg
Copy link
Member Author

jarekwg commented Nov 19, 2019

@rehmanjaffersayani
The cron job wouldn't be doing any authorisation.

Break it down into two parts:

  1. Get the oauth working (redirecting to MYOB and back, storing the final cred.state in your database, as outlined in the readme).
  2. Set up your cron job such that it uses this saved oauth state to talk to MYOB. The most, auth-wise, that you'll need to do here is refresh the token every now and again when it expires (PartnerCredentials offers methods for checking expiry and refreshing).

I'm not sure I understand what you're asking, but it seems you're just having trouble with the standard oauth2 process..
Have you got a web server running that's listening on the callback_uri you've defined?

@jarekwg jarekwg changed the title unable to setup with the package Unable to setup with the package Nov 19, 2019
@rehmanjaffersayani
Copy link

Hi @jarekwg

Still the same issue. I have attached the screenshot what I have done so far
I have click the cred.url and logged and copied the code and then set it to the verifier
Code
Screen Shot 2019-11-20 at 1 28 56 am
Error
Screen Shot 2019-11-20 at 1 28 48 am

Can you please help me out to setup this.
I would be thankful to you

@jarekwg
Copy link
Member Author

jarekwg commented Nov 20, 2019

So instead of listening on an endpoint at redirect_uri, you're just trying to read the verifier out of the URL?
First thing i see is you're not decoding the url (i can see % signs in there).
Try to start off with doing:

import urllib
urllib.parse.unquote("<the 'code' part you copied out of the url>")

If that still fails, I'd recommend spinning up a little webserver and creating an endpoint to listen on, as I'm not sure what side effects you get by trying to hack around it like this.

@rehmanjaffersayani
Copy link

Okay so @jarekwg
I fixed the issue. The issue was the code and state were together. So I remove the state and its working fine.

so now my cred is already verified.
But issue is I am not getting anything in
company_files = myob.companyfiles.all()
result
[CompanyFile:
banking
company
contacts
general_ledger
inventory
invoices
orders
purchase_bills
purchase_orders]

second, I am already an administrator of the account how do I know the credential?

@jarekwg
Copy link
Member Author

jarekwg commented Nov 20, 2019

That's it, it just looks a little weird cause we override the repr methods. See here: #18
So your company file is just company_files[0].
Try:

comp = myob.companyfiles.all()[0]
print(comp.id)
print(compt.name)
print(comp.data)

The second set of credentials you need are the companyfile credentials: These might be "Administrator" and "" (blank); I think that's the default. When you access MYOB through the Windows application, do you enter a username and password to get into the companyfile (different to your my.myob username & password)?

@jarekwg
Copy link
Member Author

jarekwg commented Dec 10, 2019

Hey @rehmanjaffersayani,

Haven't heard from you in a while. I'll assume your problem is resolved.

Cheers,

@jarekwg jarekwg closed this as completed Dec 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants