Comments (4)
Since you're not using the ads.properties file, you'll need to explicitly set your application name and network code for the Session. See withApplicationName and withNetworkCode.
I'll leave this issue open until the example is updated.
from googleads-java-lib.
I use this file https://github.com/googleads/googleads-java-lib/blob/1.36.0/examples/dfp_axis/src/main/java/dfp/axis/auth/CreateDfpSessionWithoutPropertiesFile.java and I try to modify this part
// Copyright 2014 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package dfp.axis.auth;
import com.google.api.ads.common.lib.auth.OfflineCredentials;
import com.google.api.ads.common.lib.auth.OfflineCredentials.Api;
import com.google.api.ads.common.lib.exception.OAuthException;
import com.google.api.ads.common.lib.exception.ValidationException;
import com.google.api.ads.dfp.axis.factory.DfpServices;
import com.google.api.ads.dfp.axis.v201311.Network;
import com.google.api.ads.dfp.axis.v201311.NetworkServiceInterface;
import com.google.api.ads.dfp.lib.client.DfpSession;
import com.google.api.client.auth.oauth2.Credential;
/**
-
This example demonstrates how to create a Credential and an DfpSession
-
object without using an ads.properties file.
* -
@author Ray Tsang
*/
public class CreateDfpSessionWithoutPropertiesFile {private static final String CLIENT_ID = "15xxxxxxxnt.com";
private static final String CLIENT_SECRET = "zQnEloxxxxxxxxxx60";
private static final String REFRESH_TOKEN = "1/OMxxxxxxx8OkM-unR30zcRFq6";
private static final String APPLICATION_NAME = "test";private static DfpSession createDfpSession(String clientId, String clientSecret,
String refreshToken, String applicationName) throws OAuthException,
ValidationException {
// Create a valid OAuth 2.0 credential without using a properties file.
Credential credential = new OfflineCredentials.Builder()
.forApi(Api.DFP)
.withClientSecrets(clientId, clientSecret)
.withRefreshToken(refreshToken)
.build()
.generateCredential();// Create a new DfpSession without using a properties file.
return new DfpSession.Builder()
.withApplicationName(applicationName)
.withOAuth2Credential(credential)
.build();
}public static void runExample(DfpServices dfpServices, DfpSession dfpSession)
throws Exception {
// Get the NetworkService.
NetworkServiceInterface networkService =
dfpServices.get(dfpSession, NetworkServiceInterface.class);// Gets the current network.
Network network = networkService.getCurrentNetwork();System.out.printf("Current network has network code "%s" and display name "%s".\n",
network.getNetworkCode(), network.getDisplayName());
}public static void main(String[] args) throws Exception {
if (CLIENT_ID.equals("INSERT_CLIENT_ID_HERE")
|| CLIENT_SECRET.equals("INSERT_CLIENT_SECRET_HERE")) {
throw new IllegalArgumentException("Please input your client IDs or secret. "
+ "See https://console.developers.google.com/project");
}if (REFRESH_TOKEN.equals("INSERT_REFRESH_TOKEN_HERE")) {
throw new IllegalArgumentException(
"Please input your refresh token. See GetRefreshTokenWithoutPropertiesFile.java.");
}// Create an DfpSession without using a properties file.
DfpSession dfpSession = createDfpSession(CLIENT_ID, CLIENT_SECRET, REFRESH_TOKEN, APPLICATION_NAME);
DfpServices dfpServices = new DfpServices();runExample(dfpServices, dfpSession);
}
}
But it still through exception:
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: java.net.ConnectException: Connection timed out: connect
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:java.net.ConnectException: Connection timed out: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:649)
at sun.security.ssl.SSLSocketImpl.<init>(SSLSocketImpl.java:409)
at sun.security.ssl.SSLSocketFactoryImpl.createSocket(SSLSocketFactoryImpl.java:88)
at org.apache.axis.components.net.JSSESocketFactory.create(JSSESocketFactory.java:92)
at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:191)
at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.java:404)
Kind regards
PM
from googleads-java-lib.
Can you please start a new thread in the DFP API forum? That's a more appropriate channel for support than the issue tracker.
from googleads-java-lib.
Closing per the previous comment.
from googleads-java-lib.
Related Issues (20)
- Query regarding setting keywordMinActivationBid and KewyordBid HOT 1
- Issue HOT 1
- 'java.lang.NoClassDefFoundError: com/google/protobuf/ServiceException' HOT 2
- Migrate away from apache-axis possibly to axis-2 HOT 1
- EntityLimitReachedError.ENTITY_LIMIT_REACHED | Do I need a new Sandbox? HOT 1
- Gellallorder.java under the package orderservice returnging 404 not found error HOT 1
- Not able to get v12 resources/services with latest maven dependency HOT 3
- javax.net.ssl.SSLHandshakeException: Remote host terminated the handshake
- Default branch is now `main` HOT 2
- io.grpc.NameResolver$Args$Builder.setOverrideAuthority(Ljava/lang/String;)Lio/grpc/NameResolver$Args$Builder; HOT 1
- Invalid element in com.google.api.ads.admanager.axis.v202211.ReportQuery - timeZoneType HOT 5
- Replacing dfp-axis with dfp-appengine: Exception Class isn't Throwable HOT 1
- > ![C](https://user-images.githubusercontent.com/50383553/64349736-ade46480-cfb4-11e9-8cd2-7e893cdd16e8.PNG)
- Licencia
- Licencia/apache
- Licencia-mit
- Security vulnerability issue for GAM API version 5.1.0
- Goggle Ads API v14-java.lang.NoSuchMethodError: com.google.api.client.util.escape.PercentEscaper.<init>(Ljava/lang/String;)V HOT 2
- Apache Axis Should Be Replaced by Axis 2 Due to Multiple CVEs and EOL HOT 2
- Enable keepAlive at Socket level
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from googleads-java-lib.