# Individual request web server in Zig

**URL:** <https://ziggit.dev/t/individual-request-web-server-in-zig/8378>\
**Category:** Help\
**Tags:** language, learning\
**Created:** [February 5, 2025, 2:22pm UTC](https://ziggit.dev/t/individual-request-web-server-in-zig/8378 "2025-02-05T14:22:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![egonik-unlp](https://ziggit.dev/user_avatar/ziggit.dev/egonik-unlp/32/4464_2.png) [@egonik-unlp](https://ziggit.dev/u/egonik-unlp)\
**Post date:** [February 5, 2025, 2:22pm UTC](https://ziggit.dev/t/individual-request-web-server-in-zig/8378/1 "2025-02-05T14:22:44Z")

</div>

Hello all,  
I’m very new to zig, and relatively new to programming in general. I need to get a oauth2 token to be used with the Spotify API. That flow requires me to receive a request, redirect the response and then receive another request.  
My problem is that when i use httpz, the server runs until I shut down the program (the server).  
What I would like to do is:

- Call the oauth2 flow from my main program (the one that actually works with the Spotify API) as a function f .
- Receive the request needed and eventually get the token.
- Return the token as a return value of the function f.

Is all of this possible using a library already built in zig?

Thank you very very much in advance.

---

<div class="post-metadata">

**Author:** ![vulpesx](https://ziggit.dev/user_avatar/ziggit.dev/vulpesx/32/3989_2.png) [@vulpesx](https://ziggit.dev/u/vulpesx)\
**Post date:** [February 6, 2025, 2:43am UTC](https://ziggit.dev/t/individual-request-web-server-in-zig/8378/2 "2025-02-06T02:43:33Z")

</div>

not sure how the http server running until you shut it down is a problem?

for oauth2  
a quick search gives me

> **[GitHub - nektro/zig-oauth2: HTTP handler functions to allow you to easily add...](https://github.com/nektro/zig-oauth2)**
>
> HTTP handler functions to allow you to easily add OAuth2 login support to your Zig application

unfortunately, uses zigmod instead of the builtin package manager, and looks like there are some junk files in the repo

> **[GitHub - zon-dev/oauth2: Implementation of OAuth 2.0 in Zig.](https://github.com/zon-dev/oauth2)**
>
> Implementation of OAuth 2.0 in Zig.

uses a local path for one of its dependencies, tho it looks like it’s on their github.

I would recommend using those as a reference to implement your own, or use a c library.  
such as

> **[GitHub - OpenIDC/liboauth2: OAuth 2.x and OpenID Connect C library](https://github.com/OpenIDC/liboauth2?tab=readme-ov-file)**
>
> OAuth 2.x and OpenID Connect C library

unfortunately it isn’t packaged for the zig build system so you would have to do that work.  
if you do pop it over to

> **[All Your Codebase](https://github.com/allyourcodebase)**
>
> ...are belong to Ziguanas, but we'd also be delighted to give them back! - All Your Codebase

for others to use
