# How to use "auth0-forwarded-for" header while using the Authorization Code flow

**URL:** <https://community.auth0.com/t/how-to-use-auth0-forwarded-for-header-while-using-the-authorization-code-flow/86890>\
**Category:** Get Help\
**Tags:** ip, login, auth0\
**Created:** [July 13, 2022, 12:00pm UTC](https://community.auth0.com/t/how-to-use-auth0-forwarded-for-header-while-using-the-authorization-code-flow/86890 "2022-07-13T12:00:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![seif.elmughrabi](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/seif.elmughrabi/32/33362_2.png) [@seif.elmughrabi](https://community.auth0.com/u/seif.elmughrabi)\
**Post date:** [July 13, 2022, 12:00pm UTC](https://community.auth0.com/t/how-to-use-auth0-forwarded-for-header-while-using-the-authorization-code-flow/86890/1 "2022-07-13T12:00:05Z")

</div>

We use the PHP SDK to carry out the Authentication Code Flow:

```auto
use Auth0\SDK\API\Authentication;
$auth0_api = new Authentication($auth0Domain, $auth0ClientId, $auth0ClientSecret);
$code_exchange_result = $auth0_api->code_exchange($code, $auth0BaseUrl.'/oauth/callback');

```

Recently, we migrated our code to Google Cloud and we saw that Auth0 throttles frequent attempts from our server IPs thinking they are end-user IPs.

Thus, I’m trying to pass in end-user IPs using the “auth0-forwarded-for” header. However, passing such header [doesn’t seem possible](https://auth0.github.io/auth0-PHP/classes/Auth0-SDK-API-Authentication.html#method_codeExchange) with Authorization Code Flow and I can’t find alternatives?

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [July 15, 2022, 12:07pm UTC](https://community.auth0.com/t/how-to-use-auth0-forwarded-for-header-while-using-the-authorization-code-flow/86890/3 "2022-07-15T12:07:58Z")

</div>

Previous message deleted due to SPAM reasons.

---

<div class="post-metadata">

**Author:** ![Ruthvandiver](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ruthvandiver/32/44296_2.png) [@Ruthvandiver](https://community.auth0.com/u/Ruthvandiver)\
**Post date:** [February 3, 2023, 4:45am UTC](https://community.auth0.com/t/how-to-use-auth0-forwarded-for-header-while-using-the-authorization-code-flow/86890/4 "2023-02-03T04:45:00Z")

</div>

The “auth0-forwarded-for” header is used to store the original client IP address when using the Authorization Code flow in Auth0. To use it, you need to:  
Enable the header in your Auth0 tenant settings.  
Add the header in your API or application code.  
Retrieve the header in your API or application code and use it to log or store the client IP address for auditing purposes.  
Example code in Node.js:  
// retrieve the header from the request  
const forwardedFor = req.headers[‘auth0-forwarded-for’];  
// log the header  
console.log(Forwarded for: ${forwardedFor});  
// store the header in your database  
storeIPAddress(forwardedFor);  
May be this works for you[.](https://www.upsers.app)

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [February 3, 2023, 7:33am UTC](https://community.auth0.com/t/how-to-use-auth0-forwarded-for-header-while-using-the-authorization-code-flow/86890/5 "2023-02-03T07:33:53Z")

</div>

Thanks for sharing that solution with the rest of company!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [February 17, 2023, 7:34am UTC](https://community.auth0.com/t/how-to-use-auth0-forwarded-for-header-while-using-the-authorization-code-flow/86890/6 "2023-02-17T07:34:14Z")

</div>

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