Basic Authencation using uri Module (Post)

177 views
Skip to first unread message

Mohammed Reehan

unread,
Sep 1, 2022, 1:45:31 PM9/1/22
to Ansible Project
Hello Experts, 

Need your kind help, i am running a basic POST call using ansible uri module with Basic Authencation 
below is the programtic code but i am getting 403 error.

---
-name: Request API Token
 ansible.builtin.uri:
   url: "https"//vrlcm.local/lcm/authzn/api/login"
   method: POST
   use_proxy: no
   validate_certs: false
   status_code: [200]
   force_basic_auth: yes
   url_username: "test"
   url_password: "test"
 register: response
 run_once: true
 delegate_facts: true
 no_log: false

i am getting below error, any pointers will be helpful to fix this issue. i am sure i am doing something silly.

"msg": "status code was -1 and not [200]: Request failed: <urlopen error tunnel connection failed: 403 forribidden>",
"redirected": "false",
"status": "-1"

Dick Visser

unread,
Sep 1, 2022, 5:56:53 PM9/1/22
to ansible...@googlegroups.com
On Thu, 1 Sep 2022 at 19:45, Mohammed Reehan <mohd....@gmail.com> wrote:
Hello Experts, 

Need your kind help, i am running a basic POST call using ansible uri module with Basic Authencation 
below is the programtic code but i am getting 403 error.

---
-name: Request API Token
 ansible.builtin.uri:
   url: "https"//vrlcm.local/lcm/authzn/api/login"

For starters the url is incorrect, it's got a
Semicolon mixed by a double quote 


method: POST
   use_proxy: no
   validate_certs: false
   status_code: [200]
   force_basic_auth: yes
   url_username: "test"
   url_password: "test"
 register: response
 run_once: true
 delegate_facts: true
 no_log: false

i am getting below error, any pointers will be helpful to fix this issue. i am sure i am doing something silly.

"msg": "status code was -1 and not [200]: Request failed: <urlopen error tunnel connection failed: 403 forribidden>",
"redirected": "false",
"status": "-1"

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/a4f107cf-28d8-46d8-9d56-b5760799408cn%40googlegroups.com.
--
Sent from Gmail Mobile

Mohammed Reehan

unread,
Sep 1, 2022, 6:01:20 PM9/1/22
to ansible...@googlegroups.com
Apologize for the error that , it was a typo tbh. Well the issue is still present.

Thanks
Reehan 

Mohammed Reehan

unread,
Sep 2, 2022, 1:08:46 PM9/2/22
to ansible...@googlegroups.com
Hello Experts,

Hate to follow up but looking for a help/solution 

Dick Visser

unread,
Sep 2, 2022, 2:23:36 PM9/2/22
to ansible...@googlegroups.com
On Fri, 2 Sept 2022 at 19:08, Mohammed Reehan <mohd....@gmail.com> wrote:

>>>> "msg": "status code was -1 and not [200]: Request failed: <urlopen error tunnel connection failed: 403 forribidden>",
>>>> "redirected": "false",
>>>> "status": "-1"

"urlopen error tunnel connection failed: 403 forribidden" indicates an
issue with a proxy.
But - there is some sort of typo again there (forribidden).
No problem with being impatient but please pay more attention to your
question/copy/pasting, to avoid wasting everyone's time here.

In any case, you've explicitly configured "use_proxy: no".
This leads me to suspect that your network might have implemented a
transparent proxy.
Can you confirm that the same request, from the same host, but done
manually with curl, does work?
Please post the evidence of that, so we can rule out any proxy issues.
Reply all
Reply to author
Forward
0 new messages