Re: [galaxy-dev] How to use the API when using a proxy server

2013-02-01 Thread Carl Eberhard
I'm glad that worked, Thon.

Let us know if you run into any other problems with the API in a proxy set
up.
Carl



On Thu, Jan 31, 2013 at 7:58 PM, Anthonius deBoer  wrote:

> Hi Carl,
>
> I am using the submit and get functions from the scripts/api/common.py
>
> I actually found that I just need to add authentication to the calls, so I
> added this
>
> 
> def authenticate(url, u, p):
> auth_handler = urllib2.HTTPBasicAuthHandler()
> auth_handler.add_password(realm='GALAXY@GHI. Please log in with your
> Windows account',
>   uri=url,
>   user=u,
>   passwd=p)
> opener = urllib2.build_opener(auth_handler)
> # ...and install it globally so it can be used with urlopen.
> urllib2.install_opener(opener)
>
> def make_url( api_key, url, args=None ):
> # Adds the API Key to the URL if it's not already there.
> if args is None:
> args = []
> argsep = '&'
> if '?' not in url:
> argsep = '?'
> if '?key=' not in url and '&key=' not in url:
> args.insert( 0, ( 'key', api_key ) )
> return url + argsep + '&'.join( [ '='.join( t ) for t in args ] )
>
> def get( api_key, url, user, pw ):
> # Do the actual GET.
> url = make_url( api_key, url )
> authenticate(url, user, pw)
> try:
> return simplejson.loads( urllib2.urlopen( url ).read() )
> except simplejson.decoder.JSONDecodeError, e:
> print "URL did not return JSON data"
> sys.exit(1)
> .
> .
> .
>
> 
>
> This will authenticate for each call and it seems to work nicely (if you
> add the authenticate step to each of the functions, like I did here for
> get
>
> Thon
>
> On Jan 31, 2013, at 11:44 AM, Carl Eberhard 
> wrote:
>
> Hello Anthonius,
>
> Can you elaborate on how you're invoking the API? How are you calling it?
>
> Thanks,
> Carl
>
>
>
> On Wed, Jan 30, 2013 at 6:30 PM, Anthonius deBoer wrote:
>
>> Hi,
>>
>> I am trying to use the API with my galaxy server running behind a proxy
>> server.
>> How do I pass username/password information to the API so it can actually
>> run?
>> If I use the regular API calls I get a access denied...
>>
>> Thanks
>>
>> Thon
>>
>> ___
>> Please keep all replies on the list by using "reply all"
>> in your mail client.  To manage your subscriptions to this
>> and other Galaxy lists, please use the interface at:
>>
>>   http://lists.bx.psu.edu/
>>
>
>
___
Please keep all replies on the list by using "reply all"
in your mail client.  To manage your subscriptions to this
and other Galaxy lists, please use the interface at:

  http://lists.bx.psu.edu/

Re: [galaxy-dev] How to use the API when using a proxy server

2013-01-31 Thread Anthonius deBoer
Hi Carl,I am using the submit and get functions from the scripts/api/common.pyI actually found that I just need to add authentication to the calls, so I added this def authenticate(url, u, p):    auth_handler = urllib2.HTTPBasicAuthHandler()    auth_handler.add_password(realm='GALAXY@GHI. Please log in with your Windows account',                              uri=url,                              user=u,                              passwd=p)    opener = urllib2.build_opener(auth_handler)    # ...and install it globally so it can be used with urlopen.    urllib2.install_opener(opener)def make_url( api_key, url, args=None ):    # Adds the API Key to the URL if it's not already there.    if args is None:        args = []    argsep = '&'    if '?' not in url:        argsep = '?'    if '?key=' not in url and '&key=' not in url:        args.insert( 0, ( 'key', api_key ) )    return url + argsep + '&'.join( [ '='.join( t ) for t in args ] )def get( api_key, url, user, pw ):    # Do the actual GET.    url = "" api_key, url )    authenticate(url, user, pw)    try:        return simplejson.loads( urllib2.urlopen( url ).read() )    except simplejson.decoder.JSONDecodeError, e:        print "URL did not return JSON data"        sys.exit(1)...This will authenticate for each call and it seems to work nicely (if you add the authenticate step to each of the functions, like I did here for getThonOn Jan 31, 2013, at 11:44 AM, Carl Eberhard  wrote:Hello Anthonius,Can you elaborate on how you're invoking the API? How are you calling it?Thanks,CarlOn Wed, Jan 30, 2013 at 6:30 PM, Anthonius deBoer  wrote:Hi,I am trying to use the API with my galaxy server running behind a proxy server.How do I pass username/password information to the API so it can actually run?If I use the regular API calls I get a access denied...ThanksThon___ Please keep all replies on the list by using "reply all" in your mail client.  To manage your subscriptions to this and other Galaxy lists, please use the interface at:    http://lists.bx.psu.edu/___
Please keep all replies on the list by using "reply all"
in your mail client.  To manage your subscriptions to this
and other Galaxy lists, please use the interface at:

  http://lists.bx.psu.edu/

Re: [galaxy-dev] How to use the API when using a proxy server

2013-01-31 Thread John Chilton
I don't know how to speak intelligently about this, so excuse my
imprecise language. The idea is that you need to still pass session
information (REMOTE_USER) along so JavaScript can access the API, but
for /api you need to make that optional.

I have an Apache server using TKTAuth. For that server I added this at
the end of my VirtualHost file to accomplish this.


  TKTAuthGuestLogin on


For my cloud images, I use nginx + ldap and there I added this block:

   location  /api {
proxy_set_header REMOTE_USER $remote_user;

proxy_pass  http://galaxy_app;
proxy_set_header   X-Forwarded-Host $host;
proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
}

Which looks a lot like my "location /" block but doesn't have an
auth_ldap_require statement.

Hope this helps.

-John





On Thu, Jan 31, 2013 at 1:44 PM, Carl Eberhard  wrote:
> Hello Anthonius,
>
> Can you elaborate on how you're invoking the API? How are you calling it?
>
> Thanks,
> Carl
>
>
>
> On Wed, Jan 30, 2013 at 6:30 PM, Anthonius deBoer  wrote:
>>
>> Hi,
>>
>> I am trying to use the API with my galaxy server running behind a proxy
>> server.
>> How do I pass username/password information to the API so it can actually
>> run?
>> If I use the regular API calls I get a access denied...
>>
>> Thanks
>>
>> Thon
>>
>> ___
>> Please keep all replies on the list by using "reply all"
>> in your mail client.  To manage your subscriptions to this
>> and other Galaxy lists, please use the interface at:
>>
>>   http://lists.bx.psu.edu/
>
>
>
> ___
> Please keep all replies on the list by using "reply all"
> in your mail client.  To manage your subscriptions to this
> and other Galaxy lists, please use the interface at:
>
>   http://lists.bx.psu.edu/

On Thu, Jan 31, 2013 at 1:44 PM, Carl Eberhard  wrote:
> Hello Anthonius,
>
> Can you elaborate on how you're invoking the API? How are you calling it?
>
> Thanks,
> Carl
>
>
>
> On Wed, Jan 30, 2013 at 6:30 PM, Anthonius deBoer  wrote:
>>
>> Hi,
>>
>> I am trying to use the API with my galaxy server running behind a proxy
>> server.
>> How do I pass username/password information to the API so it can actually
>> run?
>> If I use the regular API calls I get a access denied...
>>
>> Thanks
>>
>> Thon
>>
>> ___
>> Please keep all replies on the list by using "reply all"
>> in your mail client.  To manage your subscriptions to this
>> and other Galaxy lists, please use the interface at:
>>
>>   http://lists.bx.psu.edu/
>
>
>
> ___
> Please keep all replies on the list by using "reply all"
> in your mail client.  To manage your subscriptions to this
> and other Galaxy lists, please use the interface at:
>
>   http://lists.bx.psu.edu/
___
Please keep all replies on the list by using "reply all"
in your mail client.  To manage your subscriptions to this
and other Galaxy lists, please use the interface at:

  http://lists.bx.psu.edu/


Re: [galaxy-dev] How to use the API when using a proxy server

2013-01-31 Thread Carl Eberhard
Hello Anthonius,

Can you elaborate on how you're invoking the API? How are you calling it?

Thanks,
Carl



On Wed, Jan 30, 2013 at 6:30 PM, Anthonius deBoer  wrote:

> Hi,
>
> I am trying to use the API with my galaxy server running behind a proxy
> server.
> How do I pass username/password information to the API so it can actually
> run?
> If I use the regular API calls I get a access denied...
>
> Thanks
>
> Thon
>
> ___
> Please keep all replies on the list by using "reply all"
> in your mail client.  To manage your subscriptions to this
> and other Galaxy lists, please use the interface at:
>
>   http://lists.bx.psu.edu/
>
___
Please keep all replies on the list by using "reply all"
in your mail client.  To manage your subscriptions to this
and other Galaxy lists, please use the interface at:

  http://lists.bx.psu.edu/

[galaxy-dev] How to use the API when using a proxy server

2013-01-30 Thread Anthonius deBoer
Hi,I am trying to use the API with my galaxy server running behind a proxy server.How do I pass username/password information to the API so it can actually run?If I use the regular API calls I get a access denied...ThanksThon
___
Please keep all replies on the list by using "reply all"
in your mail client.  To manage your subscriptions to this
and other Galaxy lists, please use the interface at:

  http://lists.bx.psu.edu/