# ESI auth via PHP via script?

**URL:** <https://forums.eveonline.com/t/esi-auth-via-php-via-script/312218>\
**Category:** Third Party Developers\
**Created:** [May 18, 2021, 5:21pm UTC](https://forums.eveonline.com/t/esi-auth-via-php-via-script/312218 "2021-05-18T17:21:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Agrikk](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/agrikk/32/273773_2.png) [@Agrikk](https://forums.eveonline.com/u/Agrikk)\
**Post date:** [May 18, 2021, 5:21pm UTC](https://forums.eveonline.com/t/esi-auth-via-php-via-script/312218/1 "2021-05-18T17:21:08Z")

</div>

I am diving deeper into PHP and decided I’d create a market data application that would collect information from NPC stations and public player structures. I have immediately slammed into a brick wall called oauth.

I have built the ESI url that returns a good auth code like so:

[https://login.eveonline.com/v2/oauth/authorize/?response\_type=code&redirect\_uri=https://rainwalk.net&client\_id=xxxxxxx&scope=esi-markets.structure\_markets.v1&secret=xxxxxxx&state=abcdefg](https://login.eveonline.com/v2/oauth/authorize/?response_type=code&redirect_uri=https://rainwalk.net&client_id=xxxxxxx&scope=esi-markets.structure_markets.v1&secret=xxxxxxx&state=abcdefg)

that I can stick in a browser and retrieve a code. The problem is that I want to do this programmatically when I run a script and sticking it in a browser requires me to log in with username/password and select a character.

How can I send these details programmatically so I don’t have to pull an auth code from a web site every time I run the script?

---

<div class="post-metadata">

**Author:** ![Blacksmoke16](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/blacksmoke16/32/376589_2.png) [@Blacksmoke16](https://forums.eveonline.com/u/Blacksmoke16)\
**Post date:** [May 18, 2021, 5:47pm UTC](https://forums.eveonline.com/t/esi-auth-via-php-via-script/312218/2 "2021-05-18T17:47:40Z")

</div>

You can’t. That would defeat the purpose of OAuth. The proper way to go about this is to go thru the flow once, then save your `access_token` and `refresh_token`. You can use the `refresh_token` to get a new `access_token` programatically without needing the UI again.

See [Refreshing tokens | esi-docs](https://docs.esi.evetech.net/docs/sso/refreshing_access_tokens.html).

---

<div class="post-metadata">

**Author:** ![Brock\_Khans](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/brock_khans/32/409174_2.png) [@Brock\_Khans](https://forums.eveonline.com/u/Brock_Khans)\
**Post date:** [May 18, 2021, 6:36pm UTC](https://forums.eveonline.com/t/esi-auth-via-php-via-script/312218/3 "2021-05-18T18:36:18Z")

</div>

If using php I’d suggest looking into Guzzle, great module that makes it easy

---

<div class="post-metadata">

**Author:** ![Rtg\_Quack](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/rtg_quack/32/259589_2.png) [@Rtg\_Quack](https://forums.eveonline.com/u/Rtg_Quack)\
**Post date:** [May 24, 2021, 4:11pm UTC](https://forums.eveonline.com/t/esi-auth-via-php-via-script/312218/4 "2021-05-24T16:11:44Z")

</div>

Hi Agrikk,  
instead of re inventing the wheel you may consider to use a prooven implementation like this package: [GitHub - killmails/oauth2-eve: EVE Online Provider for the OAuth 2.0 Client](https://github.com/killmails/oauth2-eve)

It’s a EVE Online provider implementation against a very common OAuth2 library which is [GitHub - thephpleague/oauth2-client: Easy integration with OAuth 2.0 service providers.](https://github.com/thephpleague/oauth2-client)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/eveonline/original/3X/4/1/41ec4921cbaca7a6f9ea556e7cc20018461eae5e.png) [@system](https://forums.eveonline.com/u/system)\
**Post date:** [August 22, 2021, 4:11pm UTC](https://forums.eveonline.com/t/esi-auth-via-php-via-script/312218/5 "2021-08-22T16:11:59Z")

</div>

Closed on August 22, 2021, 4:11pm UTC

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