1

Im trying to implement oauth1 for quickbooks, using a python library requests_oauthlib. My problem is i tried setting up the quickbooks oauth as suggested by quickbooks inserting the quicbooks button. The sample code provided was:

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ipp="">
<head><meta http-equiv="Content-Type"
         content="text/html; charset=ISO-8859-1">
<title>My Connect Page</title>
<script type="text/javascript" src="https://appcenter.intuit.com/Content/IA/intuit.ipp.anywhere-1.3.2.js">
    </script>
<script type="text/javascript">
intuit.ipp.anywhere.setup({
        grantUrl: 'http://www.mycompany.com/HelloWorld/RequestTokenServlet'
        datasources: {
             quickbooks : true,
             payments : false
       },
        paymentOptions:{
              intuitReferred : true
       }
});
</head>
<body>
   <ipp:connectToIntuit></ipp:connectToIntuit>
</body>
</html>

But what it does is, it opens a new pop up like window and goes through the oauth process, but i am not able to figure out, how to get the control back to my app when the redirect happens to the redirect url mentioned, with the access token. Now the redirect url is also opened within the pop up window.

DeadDjangoDjoker
  • 534
  • 2
  • 8
  • 20

1 Answers1

2

But what it does is, it opens a new pop up like window and goes through the oauth process,

This is expected behavior. This should happen. The entire OAuth process takes place within the pop-up.

Now the redirect url is also opened within the pop up window.

It should be, this is good.

All you have to do is use window.close() to close the pop-up once the OAuth process completes.

Keith Palmer Jr.
  • 27,666
  • 16
  • 68
  • 105
  • where do i put the window.close() and when??:( – DeadDjangoDjoker May 11 '15 at 15:20
  • After OAuth completes, Intuit will forward the end-user, in the pop-up window, to your success/redirect URL. Your success/redirect URL should then display a message indicating things are connected, and call the Javascript window.close() method to close the pop-up window. – Keith Palmer Jr. May 11 '15 at 15:28
  • Im sorry but im doing it with django, so the redirect url will be handled by a django view, from which how will i call javascript function, and even if i manage that, how will i again redirect my app page to another page? – DeadDjangoDjoker May 11 '15 at 16:01
  • You literally have to copy-paste into your view file. It's that simple. You do not need to redirect anything. Just close the pop-up window, and you're done. Since it's a pop-up, your app will still be open in the background. – Keith Palmer Jr. May 11 '15 at 16:53
  • thanks Keith. I have another doubt, I implement oauth, and got all access token realmid and stored it in my database table. next time when the same user signs in how do i ensure that he doesn’t go through the same procedure(authorizing the app) again and instead check if his accesstoken exists in the table and log him in directly?..might be stupid a question but breaking my head for a while. – DeadDjangoDjoker May 11 '15 at 17:26
  • OAuth has *nothing* to do with authentication, or logging someone in. It is only concerned with giving you tokens to access QuickBooks data. DO NOT use OAuth tokens to log someone in to your application automatically. You are responsible for implementing your own user logins. Then, check your user login to see if you have OAuth tokens stored with that user login. If you do, exchange data with QuickBooks. If you don't, then show the "Connect to QuickBooks" button. – Keith Palmer Jr. May 11 '15 at 18:11
  • Thanks keith, was really helpful:) – DeadDjangoDjoker May 12 '15 at 07:11