# Oauth 2 does no work with redirect

**URL:** <https://community.postman.com/t/oauth-2-does-no-work-with-redirect/73506>\
**Category:** Help Hub\
**Tags:** authentication\
**Created:** [January 8, 2025, 11:57am UTC](https://community.postman.com/t/oauth-2-does-no-work-with-redirect/73506 "2025-01-08T11:57:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![supply-pilot-2083005](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/supply-pilot-2083005/32/31259_2.png) [@supply-pilot-2083005](https://community.postman.com/u/supply-pilot-2083005)\
**Post date:** [January 8, 2025, 11:57am UTC](https://community.postman.com/t/oauth-2-does-no-work-with-redirect/73506/1 "2025-01-08T11:57:46Z")

</div>

Hi Community Experts

I am trying to use postman to test the workings of a REST service that uses an OAuth2 authentication.  
Both the token URL and the service URL are implemented on a docker container.  
This means that the initial URL gets redirected.  
The Token URL [HTTP://server.dom.ct/gettoken](HTTP://server.dom.ct/gettoken) gets redirected to [HTTPS://server-02.dom.ct:450/oauth/token](HTTPS://server-02.dom.ct:450/oauth/token)  
and the service URL gets redirected from [HTTP://server.dom.ct/get/abc](HTTP://server.dom.ct/get/abc) to [HTTP://server-02.dom.ct:450/get/abc](HTTP://server-02.dom.ct:450/get/abc)

To get the token I need to send (using POST) the client\_id and client\_secret to the token URL.  
The token that is returned from the first url needs to be sent as “bearer” authorization in the request header in the  
following GET operation to the service URL

“manual scenario” runs OK  
I have configured the request to use OAuth2 ( Type OAuth2.0; Add authorization data to: Request Headers)

adapted settings  
And I have also switched the following settings of the GET request to ON  
Automatically follow redirects: ON (so a redirect gets executed)  
Follow original HTTP Method: ON (so the change from POST to GET during the redirect is left alone and POST is used)  
Follow Authorization header: ON (so the authorization header used with the GET request is also used in the redirected GET request

In the Autorization tab of the request I have replaced the [HTTP://server.dom.ct/gettoken](HTTP://server.dom.ct/gettoken) manually  
with [HTTPS://server-02.dom.ct:450/oauth/token](HTTPS://server-02.dom.ct:450/oauth/token)

I start my test by acquiring a new token.  
In the console I can see that [HTTPS://server-02.dom.ct:450/oauth/token](HTTPS://server-02.dom.ct:450/oauth/token) is used and produces a new token.  
I accept the token and press the blue SEND button to send the request and subsequently I get the expected output from the request

“automatic scenario”  
Now here is what I would like to change: I would prefer to be able to use the (non-redirected) URL for the token [HTTP://server.dom.ct/gettoken](HTTP://server.dom.ct/gettoken)  
instead of the redirected ([HTTPS://server-02.dom.ct:450/oauth/token](HTTPS://server-02.dom.ct:450/oauth/token))

If I do that in the above scenario changing  
On the authorization tabAccess TOken URL to [HTTP://server.dom.ct/gettoken](HTTP://server.dom.ct/gettoken)  
(leaving Client\_id and Client\_secret as is)  
(leaving the changed settings as above)

When pressing the blue SEND button I get an error

The console shows:  
POST [HTTP://server.dom.ct/gettoken](HTTP://server.dom.ct/gettoken) 301  
GET [HTTPS://server-02.dom.ct:450/oauth/token](HTTPS://server-02.dom.ct:450/oauth/token) 405  
Error: Could not complete OAuth 2.0 token request

Apparently the “automatically follow redirects” seems to work  
however the setting “Follow Original HTTP Method” does not work (POST becomes a GET) in the token acquisition phase

Any help Greatly appreciated

Regards Wouter

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [April 8, 2025, 11:58am UTC](https://community.postman.com/t/oauth-2-does-no-work-with-redirect/73506/2 "2025-04-08T11:58:47Z")

</div>

Closed on April 8, 2025, 11:58am UTC

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