Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using the API #61

Open
xiki808 opened this issue Nov 26, 2020 · 6 comments
Open

Using the API #61

xiki808 opened this issue Nov 26, 2020 · 6 comments

Comments

@xiki808
Copy link
Contributor

xiki808 commented Nov 26, 2020

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.

@vx3r
Copy link
Owner

vx3r commented Nov 29, 2020

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

@xiki808
Copy link
Contributor Author

xiki808 commented Nov 30, 2020

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

@jerry3k
Copy link

jerry3k commented Dec 10, 2020

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

@xiki808
Copy link
Contributor Author

xiki808 commented Dec 11, 2020

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="

@xiki808
Copy link
Contributor Author

xiki808 commented Dec 12, 2020

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

@andrew3203
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants