use authorization header
This commit is contained in:
parent
8d7d2f91ba
commit
7686fb84cf
1 changed files with 7 additions and 9 deletions
|
@ -126,15 +126,14 @@ def run_module():
|
|||
supports_check_mode=True
|
||||
)
|
||||
|
||||
gitea_url = module.params['gitea_url']
|
||||
username = module.params['name']
|
||||
headers = {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": "token {}".format(module.params['auth_token'])
|
||||
}
|
||||
gitea_url = module.params['gitea_url']
|
||||
gitea_token = module.params['auth_token']
|
||||
username = module.params['name']
|
||||
req_org = requests.get(
|
||||
gitea_url + '/api/v1/orgs/' + username +
|
||||
'?access_token=' + gitea_token,
|
||||
gitea_url + '/api/v1/orgs/' + username,
|
||||
headers=headers
|
||||
)
|
||||
|
||||
|
@ -170,7 +169,7 @@ def run_module():
|
|||
):
|
||||
new_data.pop('username')
|
||||
req_patch = requests.patch(
|
||||
gitea_url + '/api/v1/orgs/' + username + '?access_token=' + gitea_token,
|
||||
gitea_url + '/api/v1/orgs/' + username,
|
||||
headers=headers,
|
||||
data=json.dumps(new_data),
|
||||
)
|
||||
|
@ -182,7 +181,7 @@ def run_module():
|
|||
if req_org.status_code == 404:
|
||||
# org is requesed and does not yet exist, create
|
||||
create_req = requests.post(
|
||||
gitea_url + '/api/v1/orgs' + '?access_token=' + gitea_token,
|
||||
gitea_url + '/api/v1/orgs',
|
||||
headers=headers,
|
||||
data=json.dumps(new_data),
|
||||
)
|
||||
|
@ -202,8 +201,7 @@ def run_module():
|
|||
if req_org.status_code == 200:
|
||||
# org should be abenst and needs to be deleted
|
||||
delete_req = requests.delete(
|
||||
gitea_url + '/api/v1/orgs/' + username +
|
||||
'?access_token=' + gitea_token,
|
||||
gitea_url + '/api/v1/orgs/' + username,
|
||||
headers=headers,
|
||||
)
|
||||
result['return_code'] = delete_req.status_code
|
||||
|
|
Loading…
Reference in a new issue