Forum Discussion

caulfiedd_spurr's avatar
Apr 14, 2020

python f5 SDK 401 Unexpected Error: F5 Authorization Required

when I try to run the script below



from f5.bigip import BigIP
from f5.bigip import ManagementRoot
bigip = BigIP("host", "username", "password")


# Get a list of all pools on the BigIP and print their name and their
# members' name
pools = bigip.ltm.pools.get_collection()
for pool in pools:
    print(pool.name)
    for member in pool.members:
        print (member.name)

it promote error below:

Unexpected Error: F5 Authorization Required for uri: https://host:443/mgmt/tm/sys/

Text: '{"code":401,"message":"Authorization failed: user=https://localhost/mgmt/shared/authz/users/user resource=/mgmt/tm/sys verb=GET uri:http://localhost:8100/mgmt/tm/sys/ referrer:10.209.18.167 sender:10.209.18.167","referer":"10.209.18.167","restOperationId":115127900,"errorStack":["java.lang.SecurityException: Authorization failed: user=https://localhost/mgmt/shared/authz/users/user resource=/mgmt/tm/sys verb=GET uri:http://localhost:8100/mgmt/tm/sys/ referrer:mysource sender:mysource","at com.f5.rest.workers.EvaluatePermissions.failPermissionValidation(EvaluatePermissions.java:249)","at com.f5.rest.workers.EvaluatePermissions.access$100(EvaluatePermissions.java:24)","at com.f5.rest.workers.EvaluatePermissions$2.completed(EvaluatePermissions.java:202)","at com.f5.rest.workers.EvaluatePermissions$2.completed(EvaluatePermissions.java:186)","at com.f5.rest.workers.RolesWorker$10.completed(RolesWorker.java:963)","at com.f5.rest.workers.RolesWorker$10.completed(RolesWorker.java:954)","at com.f5.rest.workers.Cache$1.completed(Cache.java:151)","at com.f5.rest.workers.TmosRoleCache$1.completed(TmosRoleCache.java:69)","at com.f5.rest.workers.TmosRoleCache$1.completed(TmosRoleCache.java:64)","at com.f5.rest.common.RestOperation.complete(RestOperation.java:2411)","at com.f5.rest.common.RestWorker$3.completed(RestWorker.java:757)","at com.f5.rest.common.RestWorker$3.completed(RestWorker.java:746)","at com.f5.rest.common.RestOperation.complete(RestOperation.java:2411)","at com.f5.rest.tmos.shared.adapter.TmosRoleWorker$1.completed(TmosRoleWorker.java:65)","at com.f5.rest.tmos.shared.adapter.TmosRoleWorker$1.completed(TmosRoleWorker.java:58)","at com.f5.rest.tmos.shared.mcp.McpOperation.complete(McpOperation.java:377)","at com.f5.rest.tmos.shared.mcp.McpRunnableTask.run(McpRunnableTask.java:47)","at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:473)","at java.util.concurrent.FutureTask.run(FutureTask.java:262)","at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)","at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)","at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152)","at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:622)","at java.lang.Thread.run(Thread.java:748)\\n"],"kind":":resterrorresponse"}'

 

but actually , if I try to use request API , I can access https://host:443/mgmt/tm/sys/

here is the output . so what's the problem . how can I fix it .

 

{'kind': 'tm:sys:syscollectionstate', 'selfLink': 'https://localhost/mgmt/tm/sys?ver=13.1.1.4', 'items': [{'reference': {'link': 'https://localhost/mgmt/tm/sys/application?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/daemon-log-settings?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/diags?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/disk?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/dynad?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/ecm?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/file?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/fpga?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/icall?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/sflow?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/software?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/turboflex?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/url-db?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/aom?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/autoscale-group?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/cluster?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/daemon-ha?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/datastor?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/db?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/dns?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/feature-module?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/folder?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/global-settings?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/httpd?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/icontrol-soap?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/log-rotate?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/management-dhcp?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/management-ip?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/management-ovsdb?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/management-proxy-config?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/management-route?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/ntp?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/outbound-smtp?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/provision?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/scriptd?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/service?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/smtp-server?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/snmp?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/sshd?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/state-mirroring?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/syslog?ver=13.1.1.4'}}]}


  • Hello caulfiedd spurred.

    Try to put this instead

    bigip = BigIP("host", "username", "password", token=True)

    KR,

    Dario.

  • Hello caulfiedd spurred.

    Try to put this instead

    bigip = BigIP("host", "username", "password", token=True)

    KR,

    Dario.

    • Akash9920's avatar
      Akash9920
      Icon for Nimbostratus rankNimbostratus

      Hi I am facing the same error even after putting the token=True. PS: I checked credentials both are same but in case of python sdk, I am getting 401 error and in case of icontrol its giving response.

       

       

      Can you help?