You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by inteloid <ha...@gmail.com> on 2013/03/02 14:36:49 UTC

OAuth2, Client credentials: Get Client ID.

Hi, I have 2 types of grant handlers registrered:
1. Resource Owner
2. Client Credentials

When I use token provided by Resource Owner grant handler, I can easily get
UserSubject from MessageContext but having problems to get ClientID when
using Client Credentials, how to get it from a resource?



--
View this message in context: http://cxf.547215.n5.nabble.com/OAuth2-Client-credentials-Get-Client-ID-tp5723951.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: OAuth2, Client credentials: Get Client ID.

Posted by inteloid <ha...@gmail.com>.
Thank you Sergey, I'll try it out as soon as new release is out.



--
View this message in context: http://cxf.547215.n5.nabble.com/OAuth2-Client-credentials-Get-Client-ID-tp5723951p5723962.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: OAuth2, Client credentials: Get Client ID.

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
On 02/03/13 18:41, inteloid wrote:
> Thanks a lot, that worked Thorsten.
>
> I'll try to find some time for patch, thanks again.
>
>
I can see, in the latest code, that Client.getSubject() is used to 
initialize an access token Subject, when ClientCredentialsGrantHandler 
is used, so I reckon OAuthContextUtils#resolveClient should also work now...

Cheers, Sergey

>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/OAuth2-Client-credentials-Get-Client-ID-tp5723951p5723957.html
> Sent from the cxf-user mailing list archive at Nabble.com.

Re: OAuth2, Client credentials: Get Client ID.

Posted by inteloid <ha...@gmail.com>.
Thanks a lot, that worked Thorsten.

I'll try to find some time for patch, thanks again.



--
View this message in context: http://cxf.547215.n5.nabble.com/OAuth2-Client-credentials-Get-Client-ID-tp5723951p5723957.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: OAuth2, Client credentials: Get Client ID.

Posted by Thorsten Höger <li...@hoegernet.de>.
Am 02.03.2013 15:17, schrieb inteloid:
> Hi Thorsten, thanks for fast response.
>
> It throws Unauthorized exception, because there is no userSubjet, and there
> shouldn't be one, because Client acts on behalf of itself.
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/OAuth2-Client-credentials-Get-Client-ID-tp5723951p5723953.html
> Sent from the cxf-user mailing list archive at Nabble.com.
You are right, I didn't think of that when implementing this class. The problem is that
the method getContext checks the Subject.

You may want to provide a patch to handle this case.

In the meantime you can use the following code:

messagecontext.getContent(OAuthContext.class).getClientId();




Re: OAuth2, Client credentials: Get Client ID.

Posted by inteloid <ha...@gmail.com>.
Hi Thorsten, thanks for fast response.

It throws Unauthorized exception, because there is no userSubjet, and there
shouldn't be one, because Client acts on behalf of itself.



--
View this message in context: http://cxf.547215.n5.nabble.com/OAuth2-Client-credentials-Get-Client-ID-tp5723951p5723953.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: OAuth2, Client credentials: Get Client ID.

Posted by Thorsten Höger <li...@hoegernet.de>.
Am 02.03.2013 14:36, schrieb inteloid:
> Hi, I have 2 types of grant handlers registrered:
> 1. Resource Owner
> 2. Client Credentials
>
> When I use token provided by Resource Owner grant handler, I can easily get
> UserSubject from MessageContext but having problems to get ClientID when
> using Client Credentials, how to get it from a resource?
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/OAuth2-Client-credentials-Get-Client-ID-tp5723951.html
> Sent from the cxf-user mailing list archive at Nabble.com.
Hi,

you can try the method resolveClient of the OAuthContextUtils class.

Regards,
Thorsten