Python script to generate a usage report using webapi

we use sonarcloud and all repos are private. I am trying to write a python script to pull list of projects on-boarded so far for scanning

r = requests.get(‘’,headers={'Authorization’: ‘’})
I get following error {‘errors’: [{‘msg’: ‘Insufficient privileges’}]}
could someone help pls.


Hi @hkstKM,

And welcome to the community! Here’s a snippet you could use.
You should definitely use https and provide a token.
I hope this helps!


import requests

url = ''
token = 'yourtoken.....'

session = requests.Session()
session.auth = token, ''
call = getattr(session, 'get')
res = call(url)
1 Like

Thanks Alex - problem solved.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.