Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on Running DFPSession [INSERT_APPLICATION_NAME] #34

Closed
plammy opened this issue Jan 16, 2015 · 4 comments
Closed

Error on Running DFPSession [INSERT_APPLICATION_NAME] #34

plammy opened this issue Jan 16, 2015 · 4 comments
Assignees

Comments

@plammy
Copy link

plammy commented Jan 16, 2015

Hello everbody,

i'm using dfp-axis-1.33 with Eclipse. I can run the file GetRefreshTokenWithoutPropertiesFile.java and recieve refreshToken, but when I run the file CreateDfpSessionWithoutPropertiesFile.java I recieve following exception:

Exception in thread "main" Application name must be set and not be the default [INSERT_APPLICATION_NAME_HERE] caused by: [applicationName]
at com.google.api.ads.dfp.lib.client.DfpSession$Builder.validate(DfpSession.java:332)
at com.google.api.ads.dfp.lib.client.DfpSession$Builder.build(DfpSession.java:305)
at dfp.axis.auth.CreateDfpSessionWithoutPropertiesFile.createDfpSession(CreateDfpSessionWithoutPropertiesFile.java:53)
at dfp.axis.auth.CreateDfpSessionWithoutPropertiesFile.main(CreateDfpSessionWithoutPropertiesFile.java:82)

Where must I fill the applicationName? I have already filled this in the ads.properties but I don't use this.

Kind regards
PM

@christopherseeley christopherseeley self-assigned this Jan 16, 2015
@christopherseeley
Copy link
Member

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.

@plammy
Copy link
Author

plammy commented Jan 16, 2015

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

@christopherseeley
Copy link
Member

Can you please start a new thread in the DFP API forum? That's a more appropriate channel for support than the issue tracker.

@jradcliff
Copy link
Member

Closing per the previous comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants