Stuck with credentials in APIs

I’m stuck with HTTP requests for Readwise and Raindrop because of credentials. They are not recognized.

For instance, in this script, I should receive a 204 response according to Readwise API | Readwise. Instead, I get an error ‘Authentication credentials were not provided’.

I need help please!

let credential = Credential.create('Readwise', 'Highlight surfacing service.');
credential.addPasswordField('token', 'Access Token');
credential.authorize();
let token = credential.getValue('token'),
  http = HTTP.create(),
  response = http.request({
    url:'https://readwise.io/api/v2/auth/',
    method:'GET',
    headers:{
      'Authorization':`Token ${token}`
    }
  });
alert(JSON.stringify(response.responseData));

Are you sure you have a valid access token saved in the credentials? Have you tried forgetting them are re-entering the value?

I just did a quick test with a new Readwise account and got a 204 response without issue using this example script.

1 Like

Yes, I replaced a few times the credentials. I even replaced ${token} with the token itself in the script. Same error. And Readwise is only an exemple. No authentication in Raindrop too.

The script runs in Drafts on the up-to-date iOS, with no VPN. I tried to disable various settings in iCloud (private relay) and Safari (content blockers…) in case Drafts uses Safari webkit. But no way, I’m stuck.

Well, the script works well when it’s launched directly from an action. It does not work when it’s embedded in my other scripts ! I proceed with my tests. Sorry and thank you for your time :slight_smile:

My bad! Objects prototypes interfered, for instance ‘ Object.prototype.setValue’ or ‘ Object.prototype.build’… Error is terminated :slight_smile: