Using HTTP Basic-Auth with Google App Engine URLFetch service

后端 未结 6 601
眼角桃花
眼角桃花 2020-12-07 23:01

How can I specify the username and password for making Basic-Auth requests with App Engine\'s URLFetch service (in Java)?

It seems I can set HTTP headers:

         


        
6条回答
  •  有刺的猬
    2020-12-07 23:48

    For those interested in doing this in Python (as I was), the code looks like this:

    result = urlfetch.fetch("http://www.example.com/comment",
                            headers={"Authorization": 
                                     "Basic %s" % base64.b64encode("username:pass")})
    

提交回复
热议问题