[closed] Plug IBM DOORS NG OSLC REST API into Power BI
minak pori (7●2)
| asked Dec 07 '20, 12:24 p.m.
edited Oct 10 '22, 3:17 a.m. by Ralph Schoon (63.1k●3●36●45) Hi all Has anyone managed to achieve using the DOORS OSLC API in power bi? I am attempting to use a web data source with all the same URL and headers I would use with an API query however it gets stuck on the authentication page. Can't seem to find any assistance. Thanks |
The question has been closed for the following reason: "Problem is not reproducible or outdated" by rschoon Oct 10 '22, 3:17 a.m.
3 answers
Here's some Python code that you might use as a guide:
self.base_url = server_url
self.userid = user
self.password = password
self.spc = None
self.sp = None
self.ownerMap = dict()
# Disable SSL so that we can read self-assigned certificates
self.http = httplib2.Http(".cache", disable_ssl_certificate_validation=True)
self.http.follow_redirects = True
self.headers = {'Content-type': 'application/rdf+xml'}
protectedResource = "/whoami"
# Create an authentication challenge by attempting to access a protected resource
resp, content = self.http.request( self.base_url + protectedResource, 'GET', headers=self.headers)
if (resp.status == 404):
# the JRS server does not support whoami
protectedResource = ''
resp, content = self.http.request( self.base_url + protectedResource, 'GET', headers=self.headers)
if ('x-com-ibm-team-repository-web-auth-msg' in resp and resp['x-com-ibm-team-repository-web-auth-msg'] == 'authrequired'):
# JEE Forms authentication
resp, content = self.http.request( self.base_url + protectedResource, 'GET', headers=self.headers)
self.headers['Cookie'] = resp['set-cookie']
self.headers['Content-type'] = 'application/x-www-form-urlencoded'
# now we can start the authentication via j_security_check page
resp, content = self.http.request(self.base_url+'/j_security_check' , 'POST', headers=self.headers,
body=urllib.parse.urlencode({'j_username': user, 'j_password': password}))
# Successful login will set the LtpaToken2 required for subsequent authenticated access
self.headers['Cookie'] = resp['set-cookie']
else:
# Try sending the credentials for OpenIDConnect
self.http.add_credentials(user, password)
# check authentication was successful, if not throw exception
resp, content = self.http.request( self.base_url + protectedResource, 'GET', headers=self.headers)
assert (resp.status == 200), f"Login failed with status: {resp.status}"
|
Ralph Schoon (63.1k●3●36●45)
| answered Dec 07 '20, 12:43 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER For authentication see https://rsjazz.wordpress.com/2019/05/13/using-a-rest-client-to-authenticate-to-elm-clm-applications/
|
I have several clients who have tried this, and the PowerBI side is really problematic when you have to execute a login because it doesn't handle session cookies well.
To log into ELM you first need to hit a protected page and grab the session cookies, then check from the headers what method needs to be used to login. It will either be forms based login, or basic login. Then you need to supply authentication info and the session cookies from the first hit. After that you're logged in.
We found PowerBI had a lot of trouble doing the first hit and then saving cookies, but we eventually worked it out in the PowerBI UI.
The other option is to use OAuth and set up friendship between the servers.
Finally after all that we found that the authentication method was only available in the client and could not be set up on the PowerBI server to automatically be done on a schedule - I don't know if that's changed now.
|