1

I have used Google Adsense management API Java client library in my web application (built using Spring Boot) in order to use Adsense report in admin dashboard. I have used following code to establish credential.

GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow
                                       .Builder(  httpTransport, JSON_FACTORY, clientSecrets,Collections.singleton(AdSenseScopes.ADSENSE_READONLY))
                                       .setDataStoreFactory(dataStoreFactory)
                                       .setAccessType("offline")
                                       .build();
    
// authorize
LocalServerReceiver receiver = new LocalServerReceiver.Builder()
                                                      .setHost("DOMAIN NAME")
                                                      .build();


return new AuthorizationCodeInstalledApp(flow, receiver).authorize("user");

It seems that google API automatically appends HTTP and also add random ports in callback URL to give response token due to which it is unable to find the site. Also we cannot specify other ports except for 443 due to security reasons. It is working properly in local as well as development server but not in production server ( because the site is secured with https and doesn't allow random ports).

What is the alternative to solve this problem?

DevThiman
  • 920
  • 1
  • 9
  • 24
Alina
  • 56
  • 6
  • Does the request really need to be https if it's creating a local server? LocalServerReceiver only supports http, it seems. As for the port, you can set it with LocalServerReceiver.Builder.setPort, similar to how you're setting the host. – Donovan McMurray Mar 29 '19 at 19:00
  • Well actually I want to get the report in web application online, but I didn't get any resource regarding it except for using LocalServerReceiver. Can you please give me the details if there are other alternatives? – Alina Apr 01 '19 at 03:38
  • Also, I can only set port 443 to setPort (maybe because of some configuration of our server) but it seems that port below 1024 is not supported. – Alina Apr 01 '19 at 03:40

0 Answers0