You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@guacamole.apache.org by zhangbin <zh...@iat.one> on 2018/02/03 03:55:59 UTC

Login to guacamole using the web api

Hello, 

how do I use guacamole/api/tokens and login remotely to guacamole web api by
submitting username, password json format data to get the authentication
code so that direct calls to the remote desktop window can be made. 

 

Thanks for the help.

 


Re: 答复: Login to guacamole using the web api

Posted by Nick Couchman <vn...@apache.org>.
On Fri, Feb 2, 2018 at 11:16 PM, zhangbin <zh...@iat.one> wrote:

> I tried the way you said, but I'm not sure if there is a bug in my json
> format for submitting data
>

If you're submitting JSON data, then you're probably using the wrong
encoding.  You need to make sure that:
- You are submitting data with
Content-Type:  application/x-www-form-urlencoded, and that you're
submitting the username and password as form fields.  This doesn't usually
happen in JSON (although I'm sure you can do it that way), but it needs the
correct content type.
- You are submitting as a POST request, not a GET, PUT, PATCH, or DELETE.

-Nick

Re: 答复: Login to guacamole using the web api

Posted by Mike Jumper <mi...@guac-dev.org>.
On Fri, Feb 2, 2018 at 8:16 PM, zhangbin <zh...@iat.one> wrote:

> I tried the way you said, but I'm not sure if there is a bug in my json
> format for submitting data, or anything else,I get an error XMLHttpRequest
> can not load http://10.128.0.211:8080/guacamole/api/tokens. No
> 'Access-Control-Allow-Origin' header is present on the requested resource.
> Origin 'null' is therefore not allowed.
>
>
Your browser is denying the request because it violates cross-origin
policy. If you need to do this, you will need to either ensure that the
requests are not cross-origin, or use a proxy to insert the necessary CORS
headers (and enable CORS on your XMLHttpRequest instance) for the request
to succeed.

Before you go too deeply into this, though, it'd be nice to know what
you're actually planning to accomplish here. I'm not convinced this is a
good approach for ... just about anything. If you're just trying to provide
remote desktop functionality within your application powered by Guacamole,
there is an API for that (guacamole-common and guacamole-common-js) and
there is no need to embed the entire mainline web application, deal with
the REST API, etc.

- Mike

答复: Login to guacamole using the web api

Posted by zhangbin <zh...@iat.one>.
I tried the way you said, but I'm not sure if there is a bug in my json format for submitting data, or anything else,I get an error XMLHttpRequest can not load http://10.128.0.211:8080/guacamole/api/tokens. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed.

 

发件人: Nick Couchman [mailto:vnick@apache.org] 
发送时间: 当前系统时间为:2018年2月3日 12:09
收件人: user@guacamole.apache.org
主题: Re: Login to guacamole using the web api

 

On Fri, Feb 2, 2018 at 10:55 PM, zhangbin <zhangbin@iat.one <ma...@iat.one> > wrote:

Hello, 

how do I use guacamole/api/tokens and login remotely to guacamole web api by submitting username, password json format data to get the authentication code...

 

The easiest way to figure out what you need is to use something like Chrome Developer Tools, the Network tab, specifically, and watch the login process.  Basically it looks sometihng like this:

- You load the page, which posts to the tokens endpoint on the API and receives a 403 INSUFFICIENT CREDENTIALS error.

- The AngularJS web application interprets this and presents the username/password dialog

- You type your username and password, and submit

- This POSTs a application/x-www-form-urlencoded back to the token endpoint, with the username and password as form parameters.

- In response, assuming successful authentication, you receive the authToken back in the response, which you can then use as the token parameter in subsequent API calls.

 

so that direct calls to the remote desktop window can be made. 

 

 

What kind of "direct calls" are you talking about, here?  Logging into the API like this allows you to interact with the API using the token, but I'm not sure about making direct calls to a remote desktop window.  You can certainly use this method to establish a tunnel to a given connection, but if you're thinking you can authenticate to the API and then somehow send and receive data from a remote desktop session, this is not how it works - at least, not quite that easily.

 

-Nick


Re: Login to guacamole using the web api

Posted by Nick Couchman <vn...@apache.org>.
On Fri, Feb 2, 2018 at 10:55 PM, zhangbin <zh...@iat.one> wrote:

> Hello,
>
> how do I use guacamole/api/tokens and login remotely to guacamole web api
> by submitting username, password json format data to get the authentication
> code...
>

The easiest way to figure out what you need is to use something like Chrome
Developer Tools, the Network tab, specifically, and watch the login
process.  Basically it looks sometihng like this:
- You load the page, which posts to the tokens endpoint on the API and
receives a 403 INSUFFICIENT CREDENTIALS error.
- The AngularJS web application interprets this and presents the
username/password dialog
- You type your username and password, and submit
- This POSTs a application/x-www-form-urlencoded back to the token
endpoint, with the username and password as form parameters.
- In response, assuming successful authentication, you receive the
authToken back in the response, which you can then use as the token
parameter in subsequent API calls.


> so that direct calls to the remote desktop window can be made.
>
>
>

What kind of "direct calls" are you talking about, here?  Logging into the
API like this allows you to interact with the API using the token, but I'm
not sure about making direct calls to a remote desktop window.  You can
certainly use this method to establish a tunnel to a given connection, but
if you're thinking you can authenticate to the API and then somehow send
and receive data from a remote desktop session, this is not how it works -
at least, not quite that easily.

-Nick