Search code examples
copyleaks-api

Why does the sample code result in a 401 response?


Almost an identical match against the documentation example at the bottom of this page: https://api.copyleaks.com/documentation/v3/scans/submit/url#sandbox-mode

import requests
import json

headers = {
    'Content-type': 'application/json',
    'Authorization': 'Bearer [KEY]'
}

myobj = {'url':'[TARGET_URL]','properties':{'action':0,'includeHtml':False,'developerPayload':'Custom developer payload','sandbox':False,'expiration':480,'author':{'id':'Author id'},'webhooks':{'newResult':'https://[URL]/copyleaks_callback','status':'https://[URL]/copyleaks_callback'},'filters':{'identicalEnabled':True,'minorChangesEnabled':True,'relatedMeaningEnabled':True,'minCopiedWords':10,'safeSearch':False,'domains':['www.rd.com'],'domainsMode':1},'scanning':{'internet':True},'exclude':{'quotes':False,'titles':False,'htmlTemplate':False},'sensitivityLevel':3}}

response = requests.put('https://api.copyleaks.com/v3/scans/submit/url/[ID]', headers=headers, json=myobj)

Doesn't work as advertised. I asked via Copyleaks support, over email, via github, and even by DMing one of the engineers on linkedin but nobody can answer this. I don't think I'm missing anything here... right?


Solution

  • Did you replaced the [Key] with a valid authentication token?

    I guess that you answer is "yes", so please run this cURL command with your existing key:

    curl -XGET -H "Authorization: Bearer YOUR-LOGIN-TOKEN" 'https://api.copyleaks.com/v3/scans/credits'
    

    Does it working for you? If no, the problem is probably with your authentication token.