vx3r / wg-gen-web

Simple Web based configuration generator for WireGuard

Home Page:https://wg-gen-web-demo.127-0-0-1.fr

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using the API

xiki808 opened this issue · comments

Can I make use of your API externally?

So for example how can I get a response from: http:///api/v1.0/server/version?

I'm always getting a 401 Unauthorized error.

commented

are you using OAuth2 OIDC ? if yes you need to provide access token in x-wg-gen-web-auth header after authentication

No I'm not, do I need to to access the API? I will check more about this, this evening.

HOw can we not re-generate this token on every login? or maybe assign a key in docker-compose? Thanks

How can I create an access token? Can someone guide me please?

I'm sending this:
URL: /api/v1.0/auth/oauth2_url
Return:

{
    "oauth2": true,
    "clientId": "674zPDl44mbPRaF-6x4q0aHBl0ebAP7zyznOj8PNcu8=",
    "code": "",
    "state": "70etxPg9TBraUhrAdaYxBlJ8CDwZKBcB6DL-c3ziG9k=",
    "codeUrl": "_magic_string_fake_auth_no_redirect_"
}

And then send:
Url: /api/v1.0/auth/oauth2_exchange
Body:

{
	"clientid": "674zPDl44mbPRaF-6x4q0aHBl0ebAP7zyznOj8PNcu8==",
	"code": "",
	"state": "70etxPg9TBraUhrAdaYxBlJ8CDwZKBcB6DL-c3ziG9k="
}

and it returns 400 bad request.

I am not setting any authentication but opting to use fake Oauth.
The console logs this:

wireguard-webui    | [GIN] 2020/12/11 - 22:30:29 | 400 |     209.417µs |   192.168.1.211 | POST     "/api/v1.0/auth/oauth2_exchange"
wireguard-webui    | time="2020-12-11T22:30:29Z" level=error msg="saved state and client provided state mismatch" savedState="<nil>" state="70etxPg9TBraUhrAdaYxBlJ8CDwZKBcB6DL-c3ziG9k="

I changed from using Postman to Insomnia to test requests, and I didn't have the problem anymore.

Did you manage to connect via api using access token.
My token is updated every ~15 minutes. And when I generate my tokens, they don't fit here