I'm trying to integrate my Ruby on Rails app to Quickbooks Online but having trouble during oauth2.0 process. I'm geting the error;"The scope query parameter is missing from the authorization request."
from this url; https://appcenter.intuit.com/app/connect/oauth2/error?error_code=MISSING_REQUIRED_PARAMETER_SCOPE
. But I know my scope value is not missing and correct, it didn't give any error before using the same code that I used in my testing app. The code block I use for authentication is located below;
This code works under a helper called: sessions_helper.rb
def get_quickbooks_login_url
client_id = "MY_ID_KEY"
client_secret = "MY_SECRET"
oauth_params = {
site: "https://appcenter.intuit.com/connect/oauth2",
authorize_url: "https://appcenter.intuit.com/connect/oauth2",
token_url: "https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer"
}
oauth2_client = OAuth2::Client.new(client_id, client_secret, oauth_params)
redirect_uri = 'http://localhost:3000/auth_tokens/new?service=quickbooks'
grant_url = oauth2_client.auth_code.authorize_url(redirect_uri: redirect_uri, response_type: "code", state: SecureRandom.hex(12), scope: "com.intuit.quickbooks.accounting")
end
Thank your for your time.
I solved the problem. I was using the "Connect to Quickbooks"
button from minimulcasts tutorial. In my test application it didn't cause any trouble but in my real app it crashed the oAuth process. I think it's because of the javascript files in the button. The button was this;
<div>
<ipp:connectToIntuit></ipp:connectToIntuit>
<script type="text/javascript" src="https://appcenter.intuit.com/Content/IA/intuit.ipp.anywhere.js"></script>
<script>
intuit.ipp.anywhere.setup({menuProxy: '/path/to/blue-dot', grantUrl: '<%= get_quickbooks_login_url %>'});
</script>
</div>
I changed this button simply with this;
<a href="<%= get_quickbooks_login_url %>" role="button" id="connect-button" class="btn btn-info">Connect to Quickbooks</a>
And my problem is solved. But now I'm getting wrong number of arguments (given 3, expected 2)
error which I think caused by SimpleCommand
. Wish me luck.