Hi,Guys
I have a problem with FGT60E API token.
The python code is as follows:================================================================================================================================================import json,urllib3,requests
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
url = "https://X.X.X.X:4433"
fgt_url = "https://X.X.X.X:4433/logincheck"
# fgt_coo = requests.post(fgt_url,data={"username":"aaaaa","secretkey":"aaaaaaa",
# "ajax":1},verify = False)
# headers = {"Cookie":"APSCOOKIE_2405464622=%s;ccsrftoken=%s"%(fgt_coo.cookies.get("APSCOOKIE_2405464622"),
# fgt_coo.cookies.get("ccsrftoken"))}
myToken = "9qcGftQshfk9Hhqp9Gzxxx7rd14djg"
apikey = {'Authorization': 'python {}'.format(myToken)}
cmdb = url + "/api/v2/cmdb"
res = requests.get(url = cmdb,headers = apikey,verify = False)
print res.content
# result = json.loads(res.content)
# print result["version"]
# print result["serial"]
================================================================================
================================================================================
The result :
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <HTML><HEAD> <TITLE>401 Authorization Required</TITLE> </HEAD><BODY> <H1>Authorization Required</H1> This server could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials (e.g., bad password), or your browser doesn't understand how to supply the credentials required.<P> <P>Additionally, a 401 Authorization Required error was encountered while trying to use an ErrorDocument to handle the request. </BODY></HTML>
The Firewall already created API User "python" and generate key.
I used cookie its ok, but api key failed.
Can anyone help me ?
Nominating a forum post submits a request to create a new Knowledge Article based on the forum post topic. Please ensure your nomination includes a solution within the reply.
Any ideas ?
Take a look here in some examples: https://github.com/barbosm/gatepy
maybe can help you..
Regards, Paulo Raponi
p****oni wrote:Many thanks !!Take a look here in some examples: https://github.com/barbosm/gatepy
maybe can help you..
You have Reference document
I had similar problem (error 401).
In my case, the Token had an extra '\n'.
Confirm the url sent with res.url.
Select Forum Responses to become Knowledge Articles!
Select the “Nominate to Knowledge Base” button to recommend a forum post to become a knowledge article.
User | Count |
---|---|
1720 | |
1094 | |
752 | |
447 | |
234 |
The Fortinet Security Fabric brings together the concepts of convergence and consolidation to provide comprehensive cybersecurity protection for all users, devices, and applications and across all network edges.
Copyright 2024 Fortinet, Inc. All Rights Reserved.