github/developer.github.com — Issue #56: Using Github API from the browser
Author: vjeux
Created: 2012-02-16 09:56:52+00:00
State: open

I'm trying to create gists from a browser application. It sounds easy, just make a POST request to the /gists url.

**Attempt 1 - CORS**
-------

First I tried with jQuery.post() but it throws me an error

XMLHttpRequest cannot load https://api.github.com/gists/.
Origin http://fooo.fr is not allowed by Access-Control-Allow-Origin.

Looking at the [Cross Origin Resource Sharing](http://developer.github.com/v3/#cross-origin-resource-sharing), it says:

Any domain that is registered as an OAuth Application is accepted.

I tried to google how to register my domain to be an OAuth Application but I couldn't find anything. Do you have a link that explains the process?

**Attempt 2 - JSON-P**
-------

Since CORS was a dead-end, I tried to look at JSON-P.

You can send a ?callback parameter to any GET call to have the results wrapped in a JSON function.

Well, this works for ```GET``` calls but I can't find a way to specify a ```POST``` call and how to pass arguments.

So now I'm stuck :( I hope some of you have a solution! Thanks :)