Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authorization Header seems to be not send or something #407

Closed
Kageetai opened this issue Nov 14, 2014 · 3 comments
Closed

Authorization Header seems to be not send or something #407

Kageetai opened this issue Nov 14, 2014 · 3 comments

Comments

@Kageetai
Copy link

Hi there,

I am trying to upload an image to imgur with this code which I derived from #88 but I always get 403 (Permission Denied)

Here is my code in the controller so far:

$scope.onFileSelect = function (files) {
      var fileReader = new FileReader();
      fileReader.readAsArrayBuffer(files[0]);
      fileReader.onload = function (e) {
        $upload.http({
          url: 'https://api.imgur.com/3/image',
          //method: 'POST',
          headers: {
            'Authorization': 'Client-ID XXXXXXXXXXXXXX',
            'Content-Type': files[0].type
          },
          data: e.target.result
        }).then(function (response) {
          console.log(data);
        }, null, function (evt) {
          //$scope.progress[index] = parseInt(100.0 * evt.loaded / evt.total);
          console.log(parseInt(100.0 * evt.loaded / evt.total));
        });
      };
    };

And here a screenshot of the request in the Chrome network panel. I noticed the authorization header is different there.
capture

@danialfarid
Copy link
Owner

I don't believe the plugin do anything funny with the headers so it is probably traceable in your code.
You can try the demo page code and send a custom header to see if it's being sent correctly.

@Kageetai
Copy link
Author

So I tried everything now, copied your exact demo code, tried a blank request with the angular $http and more, but everytime I get the same "403 (Permission denied)".
If I try the same request with a tool to test REST services it works fine.
I am kinda desperate by now and don't see anything wrong in my code or something. Am I setting the authorization header wrong?

@danialfarid
Copy link
Owner

If you could create a jsfiddle to show the error I can investigate more, you can reopen the issue if you do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants