Can't use Trello client.js API with localhost 'This request came from an unauthorized domain'

StackOverflow https://stackoverflow.com/questions/22408255

  •  14-06-2023
  •  | 
  •  

سؤال

I am trying to use the Trello client.js to create an application on a local web server (Visual Studio 2013). When I try to authorize my app, I get this error from Trello.com.

This request came from an unauthorized domain

I used the jsfiddle example listed in the Trello API docs. I copied all the javascript and referenced the client.js file with my generated key.

I can't find any reference on the internet for that error message. My best guess is that Trello doesn't allow localhost because it needs to talk to the server you are calling it from?

Code I used. I called this from Chrome console and received the error above.

Trello.authorize({
    type: "popup",
    success: onAuthorizea,
    scope: { read: true }
});

I supposed I could authorize my app outside of localhost, then use that token for all future requests to the API, but I don't see an option to supply the token when using the client.js method.

هل كانت مفيدة؟

المحلول

You need to specify your own application key in the query string to client.js:

<script src="https://api.trello.com/1/client.js?key=your_application_key">

I believe you are using the key that is used for the jsfiddle example, which is one of the only keys that restricts domains. You can find your personal key here.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top