Skip to content

Authentication problems #28

@martin-g

Description

@martin-g

Hi,

I am trying to use this library and I am having problems to use the OAuth authentication.

My code is:


    private static final String CLIENT_ID = "MY_CLIENT_ID_HERE";
    private static final String CLIENT_SECRET = "MY_SECRET_HERE";

    public static void main(String[] args) throws Exception {
        AnalyticsClient client = new AnalyticsClientBuilder()
                .setEndpoint("api2.omniture.com")
                .authenticateWithClientCredentialsOAuth(CLIENT_ID, CLIENT_SECRET)
                .build();

        ReportSuiteMethods suiteMethods = new ReportSuiteMethods(client);
        CompanyReportSuites reportSuites = suiteMethods.getReportSuites();
        for (CompanyReportSuite suite : reportSuites.getReportSuites()) {
            System.out.println("Suite: " + suite);
        }
  }

Pretty much as in the README: https://github.com/Adobe-Marketing-Cloud/analytics-java-library/blob/master/README.md#L176-L179

But it fails with:

Exception in thread "main" com.adobe.granite.analytics.client.ApiException: invalid_client (The client credentials are invalid)
	at com.adobe.granite.analytics.client.ConnectionUtil.readResponse(ConnectionUtil.java:25)
	at com.adobe.granite.analytics.client.auth.OAuthenticator.getToken(OAuthenticator.java:63)
	at com.adobe.granite.analytics.client.auth.OAuthenticator.authenticate(OAuthenticator.java:44)
	at com.adobe.granite.analytics.client.AnalyticsClient.callMethod(AnalyticsClient.java:43)
	at com.adobe.granite.analytics.client.AnalyticsClient.callMethod(AnalyticsClient.java:31)
	at com.adobe.granite.analytics.client.methods.ReportSuiteMethods.getReportSuites(ReportSuiteMethods.java:34)
	at test.AdobeDriver.main(AdobeDriver.java:41)

I get the CLIENT_ID and the SECRET_ID from https://console.adobe.io/integrations/XXXXX/YYYYY/overview (XXXXX and YYYYY are numbers).

What could be the problem ?
Is it that this library still uses the 1.4 APIs -

final URL url = new URL(String.format("https://%s/admin/1.4/rest/?method=%s", endpoint, method));
?

Should I follow the JWT approach (https://github.com/AdobeDocs/analytics-2.0-apis/tree/master/examples/jwt/java) ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions