Go back to the main page

Migrating a QuickBooks Online App from OAuth1 to OAuth2 using the qbo_api gem - Step 3

 

Show notes:

  • In short this tutorial is about creating OAuth2 access tokens given that you have valid OAuth1 tokens using the Migration API.
  • To see the Qbo::OAuth2.migrate! code see the Step 2 article.

lib/tasks/quickbooks.rake


namespace :quickbooks do

    task :oauth2_migrate => :environment do
        qbo_accounts = QboAccount.all
        qbo_accounts.each do |qbo_account|
            next unless qbo_account.id == 3 # Remove this line later of course
            begin
                Qbo::OAuth2.migrate!(qbo_account)
                puts "SUCCESS_OAUTH2_MIGRATION_FLAG: qbo_account_id: #{qbo_account.id}"
            rescue => e
                puts "FAILED_OAUTH2_MIGRATION_FLAG: qbo_account_id: #{qbo_account.id} error_message: #{e.message}"
            end
        end
    end
end