1

I have followed the Web: Getting Started Samples. When the function AdobeCreativeSDK.init is called it invoke https://adobeid-na1.services.adobe.com/ims/check/v4/token first with request method OPTIONS and then with request method POST, both returning status code 200 OK. The response to the POST request returns {"error":"invalid_credentials"} and I do not know why and how to solve this.

Any help will be appreciated.

Community
  • 1
  • 1
Raanan Avidor
  • 3,533
  • 4
  • 25
  • 32

1 Answers1

5

Troubleshooting:

Do you see something like this in your console?

XMLHttpRequest cannot load https://adobeid-na1.services.adobe.com/ims/check/v4/token. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://your.domain.com' is therefore not allowed access.

Then you likely do not have a valid SSL certificate.


From the documentation:

From Adobe's Getting started with the Creative SDK for Web:

If you get an XMLHttpRequest error due to 'Access-Control-Allow-Origin', there is likely an issue with your SSL setup (as noted in the “Prerequisites” section of this guide, SSL is required).

And here's what's stated in the Prerequisites section [emphasis added]:

Prerequisites

  1. Before you can work with the Creative SDK, you must register your application and get Client ID (API Key) and Client Secret values. For details, see the “Registering Your Application” section of this guide.

  2. The following software is required:

    • Supported browsers: Chrome 53+, Safari 9+, Firefox 45+, Edge, IE11+
    • SSL required: Your site must support SSL on any page that integrates the Creative SDK.

Possible Solution:

If you're testing on your dev machine from localhost, then you'll need to modify your hosts file and setup your own domain mapped to 127.0.0.1, then you'll need to configure a self-signed certificate on your server.

You may also want to check out How to use locally (from their Github repo) which has this wonderful gem:

openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes

Helpful Resources:


How I got it working:

1. Adobe I/O Setup:

Here's how my test application was configured on Adobe I/O:

enter image description here

2. Local HTTP Server (SSL)

At the root, to create a self-signed cert, run:

openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes

Then, I've setup a simple python server that uses that self-signed cert server.pem created above:

# ./start.py
import BaseHTTPServer, SimpleHTTPServer
import ssl

httpd = BaseHTTPServer.HTTPServer(('localhost', 4443), SimpleHTTPServer.SimpleHTTPRequestHandler)
httpd.socket = ssl.wrap_socket (httpd.socket, certfile='server.pem', server_side=True)
httpd.serve_forever()

Started my server

python ./start.py

3. Hit https://localhost:4443

Important Note: You will get an 200 response with the following payload: {"error":"invalid_credentials"} on that second call. As long as you don't get a console error, your web app is ready.

As per the documentation, I added a button with csdk-login to test the User Auth UI api.


4. Fully working code

File structure:

/app
├── config.js <-- my clientId config
├── index.html
├── index.js
├── server.pem <-- my self-signed cert
└── start.py  <-- my server

HTML:

<!DOCTYPE html>
<html>
<head>
    <title>Technophobia: SDK Getting Started</title>
</head>
<body>
    <h1>Adobe Creative SDK</h1>
    <p>Look at the console</p>

    <button id="csdk-login">Log in to Creative Cloud</button>

    <script type="text/javascript" src="https://cdn-creativesdk.adobe.io/v1/csdk.js"></script>
    <script type="text/javascript" src="config.js"></script>
    <script type="text/javascript" src="index.js"></script>

</body>
</html>

JS:

/* 1) Initialize the AdobeCreativeSDK object */
AdobeCreativeSDK.init({
    /* 2) Add your Client ID (API Key) */
    clientID: CONFIG.CSDK_CLIENT_ID, //
    API: ["Asset"],
    onError: function(error) {
        /* 3) Handle any global or config errors */
        if (error.type === AdobeCreativeSDK.ErrorTypes.AUTHENTICATION) {
            console.log('You must be logged in to use the Creative SDK');
        } else if (error.type === AdobeCreativeSDK.ErrorTypes.GLOBAL_CONFIGURATION) {
            console.log('Please check your configuration');
        } else if (error.type === AdobeCreativeSDK.ErrorTypes.SERVER_ERROR) {
            console.log('Oops, something went wrong');
        }
    }
});

/* 1) Add a click handler to a button that calls a helper function */
document.getElementById("csdk-login").addEventListener('click', handleCsdkLogin, false);

/* 2) Make a helper function */
function handleCsdkLogin() {

    /* 3) Get auth status */
    AdobeCreativeSDK.getAuthStatus(function(csdkAuth) {

        /* 4) Handle auth based on status */
        if (csdkAuth.isAuthorized) {
            // The user is logged in and has authorized your site.
            console.log('Logged in!');
        } else {
            // Trigger a login
            AdobeCreativeSDK.login(handleCsdkLogin);
        }
    });
}
Community
  • 1
  • 1
technophobia
  • 2,644
  • 1
  • 20
  • 29
  • I do get the 'Access-Control-Allow-Origin' error but my SSL certificate is valid (I've checked it with https://www.sslshopper.com/ssl-checker.html) the certificate should be trusted by all major web browsers (all the correct intermediate certificates are installed), the certificate will expire in 281 days and my hostname is correctly listed in the certificate. – Raanan Avidor Feb 19 '17 at 07:49
  • By the way, our SSL certificate is issued by Amazon. – Raanan Avidor Feb 19 '17 at 08:58
  • Following the instructions on "How to use locally" and running my application on a simple Python server, I was able to suppress that error and continue testing my application. I'll update the answer with some more (hopefully useful) information for you. – technophobia Feb 19 '17 at 15:30
  • @RaananAvidor I update the answer - have a look at how I got mine working, perhaps it will help you with your issue(s). – technophobia Feb 19 '17 at 16:00
  • Thank you very much. You have earned your bounty :) – Raanan Avidor Feb 20 '17 at 13:39