I am using Wordpress and Jetpack on a self hosted WP site and I would like to use the Wordpress REST API to create posts from a different application also on the web using just HTML & JQuery.
I can get the unauthenticated data but when I try and add a new post it requires an access token.
I have written the following,
        wpAuth.bind('click', function(){
            $.ajax({
                url: "https://public-api.wordpress.com/oauth2/token",
                dataType: "json",
                data: {
                    'client_id': 'client id',
                    'client_secret': 'secret token',
                    'grant_type': 'password',
                    'username': 'wp.comuser',
                    'password': 'a password',
                },
                type: 'POST',
                success: function( response ) {
                    console.log( response ); // server response
                }
            });             
        });
But I get an error:
XMLHttpRequest cannot load https://public-api.wordpress.com/oauth2/token. Origin http://example.com is not allowed by Access-Control-Allow-Origin.
Can someone help me understand what is the problem, I have the Javascript Origins setup at developer.wordpress.com for my app.
