# Problem with httpget authentification

**URL:** <https://forum.inductiveautomation.com/t/problem-with-httpget-authentification/11226>\
**Category:** Ignition\
**Created:** [February 17, 2016, 4:08pm UTC](https://forum.inductiveautomation.com/t/problem-with-httpget-authentification/11226 "2016-02-17T16:08:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fabrice\_CHAVEROT](https://avatars.discourse-cdn.com/v4/letter/f/ecc23a/32.png) [@Fabrice\_CHAVEROT](https://forum.inductiveautomation.com/u/Fabrice_CHAVEROT)\
**Post date:** [February 17, 2016, 4:08pm UTC](https://forum.inductiveautomation.com/t/problem-with-httpget-authentification/11226/1 "2016-02-17T16:08:15Z")

</div>

I have the following python function wich works, but Java asks me for authentification (with a popup) although I pass the good username and password. Is there a way to resolve this problem or a workaround ?

I am on W7, Ignition 7.6 and Java RE 1.7

def httpGetEwonRtValues(lnk,usr,pwd):  
import system  
rtvalues=[]  
logger = system.util.logger(“ewonRTvaluesGetter”)  
try:  
response = system.net.httpGet(url=lnk,username=usr,password=pwd)  
lines=response.split(’\n’)  
variableLine=False  
for line in lines:  
if line.find(’’)!=-1:  
break  
if variableLine==True:  
words=line.split(’;’)  
if len(words)==6:  
TagId=words[0]  
TagName=words[1]  
Value=words[2]  
AlStatus=words[3]  
AlType=words[4]  
Quality=words[5]  
rtvalue=(TagId,TagName,Value,AlStatus,AlType,Quality)  
rtvalues.append(rtvalue)  
if line.find(‘TagId’)!=-1 and line.find(‘TagName’)!=-1:  
variableLine=True  
except:  
import sys  
from java.lang import Exception  
exceptionType, exception, stacktrace = sys.exc\_info()  
if exceptionType == Exception:  
exception = exception.getCause()  
exceptionName = exception. **class**. **name**  
logger.error(exceptionName+" : “+str(exception)+” url: “+lnk+” usr: “+usr+” pwd: "+pwd)  
return rtvalues

---

<div class="post-metadata">

**Author:** ![JGJohnson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jgjohnson/32/29582_2.png) [@JGJohnson](https://forum.inductiveautomation.com/u/JGJohnson)\
**Post date:** [February 17, 2016, 6:53pm UTC](https://forum.inductiveautomation.com/t/problem-with-httpget-authentification/11226/2 "2016-02-17T18:53:38Z")

</div>

That is the same problem I ran into when trying to access a password protected server.

I had to use Java authentication before making the httpGet call.

Here are a couple of functions I use to do that.

[code]def set\_authentication(username, password):  
“”" This function overrides the getPasswordAuthentication method of the java.net.Authenticator so  
the login credentials will be supplied to security enabled servers when http requests are initiated.  
“”"  
from [java.net](http://java.net) import Authenticator  
from [java.net](http://java.net) import PasswordAuthentication

```
Authenticator.setDefault(None)
class CustomAuthenticator(Authenticator):
	@staticmethod
	def getPasswordAuthentication():
		return PasswordAuthentication(username, password)
a = CustomAuthenticator()
Authenticator.setDefault(a)

```

def clear\_authentication():  
“”" This function clears the credentials from java.net.Authenticator. The previous values are  
still cached and will be sent when subsequent calls are made to the same server but this  
function should keep the cached credentials from being sent when requests are made to a  
different server.  
“”"  
from [java.net](http://java.net) import Authenticator  
Authenticator.setDefault(None)[/code]

Edited to fix typo

---

<div class="post-metadata">

**Author:** ![Fabrice\_CHAVEROT](https://avatars.discourse-cdn.com/v4/letter/f/ecc23a/32.png) [@Fabrice\_CHAVEROT](https://forum.inductiveautomation.com/u/Fabrice_CHAVEROT)\
**Post date:** [February 18, 2016, 10:38am UTC](https://forum.inductiveautomation.com/t/problem-with-httpget-authentification/11226/3 "2016-02-18T10:38:21Z")

</div>

Hello,

Thank’s a lot!!

I have inserted the call of your 2 functions before the call system.db.httpGet and it seems to worh now!!

No more Java authentication popups !!
