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?