Google DoubleClick AdExchange API integration in Rails

364 views Asked by At

I am using google-api-ruby-client gem to interact with Google DoubleClick AdExchange Seller API. I followed the procedure suggested by the Google Developers. I set redirection URI and other necessary configurations. Please find the below code snippet, which is a service setup method to get authorization and to create a service object

def service_setup
  client = Google::APIClient.new(
           :application_name => 'PMP',
           :application_version => '1.0.0'
  )

  client_secrets = Google::APIClient::ClientSecrets.load(ENV['Google_ADX_CREDENTIAL_STORE_FILE'])
  file_storage = Google::APIClient::FileStorage.new('test2')
  flow = Google::APIClient::InstalledAppFlow.new(
        :client_id => client_secrets.client_id,
        :client_secret => client_secrets.client_secret,
        :scope => ENV['Google_ADX_API_SCOPE'],
        :redirect_uri => "http://fakemydomain.com:3000"
  )
  client.authorization = flow.authorize(file_storage)
end

When I run this method,I am successfully redirecting to google accepting page like (https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=XXX...) But once I click on Accept button, the web page is keep on loading. Strangely, when I press Ctrl+C at rails server then web page redirect to the redirection URI that what I set at oauth settings.

I really appreciate any help you can provide.

0

There are 0 answers