It's all about the answers!

Ask a question

Use OAuth instead of Basic Authentication with Plain Java API


2
2
Ana-Maria Rosu (4810) | asked Jun 29 '23, 7:06 a.m.

Hello everyone,


We're currently working with the Plain Java API and we've been using the authentication with user and password as a way to obtain the ITeamRepository.

For Basic Authentication we're using the registerLoginHandler function as follows:
ITeamRepository repository = TeamPlatform.getTeamRepositoryService().getTeamRepository(repositoryAddress);
repository.registerLoginHandler(new ITeamRepository.ILoginHandler() {
            public ILoginInfo challenge(ITeamRepository repository) {
                return new ILoginInfo() {
                    public String getUserId() {
                        return user;
                    }
                    public String getPassword() {
                        return password;
                    }
                };
            }
        });
repository.login(monitor);

Now we want to try out the token-based Authentication and I noticed there's this function in ITeamRepository:
void registerOAuthHandler(IOAuthHandler var1);
but I did not find any example how to use it.

Could you please let me know if there's any examples? I looked a bit in the Javadocs but I could not find anything useful.

Thanks in advance,
Ana


Comments
Michael Rowe commented Jun 29 '23, 5:02 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR

Ralph's answer below will go in the POJO in detail.. I have also created a few blog posts which will explain the Oauth 1.0a and OIDC methods from a rest perspective -- OIDC - https://michaelrowe01.com/index.php/day-job/ibm-elm/api-authentication-method-in-elm-oidc/

2 answers



permanent link
Ralph Schoon (63.6k33646) | answered Jun 29 '23, 10:20 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

 If you follow https://jazz.net/library/article/1000 and set up the development environment based on Lab 1 until end of Lab 1, you can search for references in the EWM/RTC SDK. There are very few (like 3) examples how this is used in the SDK. 


permanent link
Julian Hemm (58616) | answered Apr 12, 2:43 a.m.

Hello,

I want to open up this question again, as I am trying to achieve the same.
Using any HttpClient, I am able to perform the oAuth1.0 dance and to receive an authenticated oAuth Acess Token.

Now, I want to make use of this token within the RTC Java SDK. I want to avoid the username / password authentication using the ILoginHandler, but what I have seen so far, logging in into the RemoteTeamRepository without a Username/Password Loginhandler is not possible at all. Can you confirm this?

I have also checked the sources as mentioned by Ralph Schoon, but still I could not figure out, how and when the IOAuthHandler is being used.

Use Case: We have a stateless WebServer that the users can request in parallel to perform several RTC actions, like reading workitems or SCM data. Instead of using the users credentials, we want to have a friendship relation (Consumer) with CLM, and use oAuth, so that we need to exchange and verify the oAuth token only.

Is there any way to achieve this or is there any sample available on how to use oAuth within the RTC Java SDK?

Any help or guidance is appreciated.
Thank you. 


Comments
Ralph Schoon commented Apr 12, 3:05 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Please create your own question.

Do not answer the question from someone else with your own question. Use the convert to question button.

If you want to, you can comment here e.g. with a link to your own question.

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.