0
Completed

Authenticated Upload via Javascript

alex bob 8 years ago • updated by Alan Schaaf (Founder) 7 years ago 6
Hi, I am creating a webapp in javascript simply for myself to upload images to imagur under my account. I currently have the anonymous setup fine and working well in javascript. I have tried using both OAuth and cookies for a javascript authenticated upload but I haven't been unable to achieve any success, also OAuth isn't really the right technology for what I would like to do (since it is specific to my account). Is this anyway I could do this/ anything you could implement in the near future?

Thanks :)

Answer

Answer
Completed
It sounds like the Cookie auth is what you need. How come it's not working for you? Could you send some code over to me so I can take a look?
Answer
Completed
It sounds like the Cookie auth is what you need. How come it's not working for you? Could you send some code over to me so I can take a look?
sure, here is my current code: http://jsfiddle.net/msm595/9arFd/101/ . it is a drag and drop interface, then click upload to upload the image. I have removed my password from the code.
+1
It doesn't look like your sending the cookie. You're just making the call to /signin and then making another call to /account/images. The two calls don't know about each other at all. You need to save the session info returned from /signin and send it with your upload.
+1
hmm, do you know how that would work in javascript?
Sorry, I do not :( I think google might be your best bet in this case.
I got an interesting error in chrome actually, i didn't notice it before: "XMLHttpRequest cannot load http://api.imgur.com/2/signin. Cannot use wildcard in Access-Control-Allow-Origin when credentials flag is true."
Hi,

I am also trying to upload using the OAuth. Somehow I can't sign in. What data should I send when I'm calling the signin? I am using .net and currently generates most of the request myself.

I have tried my code with the anonymous method and it worked fine. Somehow I'm stuck with the OAuth part, specifically at sign in.

Am I missing something?
Anyone could help here?

Thanks.

PS:
This is the error shown:
<?xml version="1.0" encoding="utf-8"?><error><message>The consumer_key "xxx" token "yyy" combination does not exist or is not enabled.</message><request>/2/signin</request><method>get</method><format>xml</format><parameters>oauth_consumer_key = xxx, oauth_n</parameters></error>