[Fiware-lab-help] Get access token using android library

Sándor Laki laki.sandor at wigner.mta.hu
Fri Jul 3 14:17:35 CEST 2015


Dear Pedro,

I have just forwarded your request to the developers of FIWARE IdM. They 
will contact you soon.

Best,
Sandor
-- on behalf of level-1 support team

2015.07.03. 11:47 keltezéssel, Pedro Gonçalves írta:
> In attachment you'll find a printscreen of the request made by Google 
> REST Advanced Client.
>
> With *URL *copied from *Request getUrl*
> *Authorization *Header copied from *Request getHeaders[authorization]*
> and *Payload* copied from *Request getContent*
>
> On Fri, Jul 3, 2015 at 10:39 AM, Pedro Gonçalves <pgoncalves at plux.info 
> <mailto:pgoncalves at plux.info>> wrote:
>
>     Hi,
>
>     I'm using an android library to get the access token using
>     explicit authentication.
>
>     API: https://github.com/wuman/android-oauth-client
>
>     This API is build on top of google API:
>     https://github.com/google/google-oauth-java-client
>
>     The authorization token is being retrieved correctly. The problem
>     is when I try to exchange it for an access_token.
>
>     Here is my request using the API:
>
>     AuthorizationFlow flow =newAuthorizationFlow.Builder(
>              //BearerToken.authorizationHeaderAccessMethod(),
>              //BearerToken.queryParameterAccessMethod(),
>              BearerToken.formEncodedBodyAccessMethod(),
>              OAuth.HTTP_TRANSPORT,
>              OAuth.JSON_FACTORY,
>              newGenericUrl(LoginConstants.TOKEN_SERVER_URL),
>              newBasicAuthentication(LoginConstants.CLIENT_ID,
>                                      LoginConstants.CLIENT_SECRET),
>              LoginConstants.CLIENT_ID,
>              LoginConstants.AUTHORIZATION_CODE_SERVER_URL)
>              .setScopes(Lists.<String>newArrayList())
>              .setCredentialStore(credentialStore)
>              .build();
>
>     DocString:
>     /**
>
>       *@parammethodmethod of presenting the access token to the resource
>       *            server (for example
>       *            {@linkBearerToken#authorizationHeaderAccessMethod})
>       *@paramtransportHTTP transport
>       *@paramjsonFactoryJSON factory
>       *@paramtokenServerUrltoken server URL
>       *@paramclientAuthenticationclient authentication or {@codenull} for
>       *            none (see
>       *            {@linkTokenRequest#setClientAuthentication(HttpExecuteInterceptor)}
>       *            )
>       *@paramclientIdclient identifier
>       *@paramauthorizationServerEncodedUrlauthorization server encoded URL
>       */
>     publicBuilder(AccessMethod method,
>              HttpTransport transport,
>              JsonFactory jsonFactory,
>              GenericUrl tokenServerUrl,
>              HttpExecuteInterceptor clientAuthentication,
>              String clientId,
>              String authorizationServerEncodedUrl)
>
>     I've been able to Intercept the Request and Response, and this is
>     the result:
>
>     Request:
>
>     *Request getUrl: *https://account.lab.fiware.org/oauth2/token
>     *Request getRequestMethod:* POST
>     *Request getHeaders:* {accept=[application/json],
>     accept-encoding=[gzip], authorization=[Basic
>     MzNkYTk0NzFjZWQyNGFmMDk1ZDhiMDg0OWY1YTY0YmE6Yjc4M2Q5NmIwMzIxNGMxOWJmYjEyMzI5OGNjZDA2ZmM=]}
>     *Request getContent:*
>     code=QqU5dSHksT13hyb5yUMqZLGpge5S1f&grant_type=authorization_code&redirect_uri=http%3A%2F%2Flocalhost%2FCallback&scope
>     *Request getTransport:*
>     com.google.api.client.http.javanet.NetHttpTransport at 1182878e
>     *Request getResponseHeaders:* {content-type=[application/json],
>     date=[Fri, 03 Jul 2015 09:27:16 GMT], connection=[close],
>     content-language=[en], server=[Apache/2.4.7 (Ubuntu)],
>     transfer-encoding=[chunked], vary=[Accept-Language,Cookie],
>     x-android-received-millis=[1435915582841],
>     x-android-response-source=[NETWORK 400],
>     x-android-sent-millis=[1435915582737], x-frame-options=[SAMEORIGIN]}
>
>     Response:
>
>     *Response getStatusCode: *400
>     *Response getStatusMessage:* Bad Request
>     *Response getHeaders:* {content-type=[application/json],
>     date=[Fri, 03 Jul 2015 09:27:16 GMT], connection=[close],
>     content-language=[en], server=[Apache/2.4.7 (Ubuntu)],
>     transfer-encoding=[chunked], vary=[Accept-Language,Cookie],
>     x-android-received-millis=[1435915582841],
>     x-android-response-source=[NETWORK 400],
>     x-android-sent-millis=[1435915582737], x-frame-options=[SAMEORIGIN]}
>     *Response getMediaType:* application/json
>     *Response getTransport:*
>     com.google.api.client.http.javanet.NetHttpTransport at 1182878e
>     *Response getContentType*: application/json
>     *Response getContent:*
>     {
>        "error" : ""
>      }
>
>     IMPORTANT: I AM able to get the access token by using Chrome's
>     REST client with the
>     *_SAME_ Request getContent* given above and the *_SAME_
>     **Authorization: Basic XXX*also given above, so they are correct.
>     I've tried to had Content-Type:application/x-www-form-urlencoded
>     to the request, but the error resulting was the same.
>     I AM able to use this API with another Identity Management
>     Servers, like foursquare.
>
>     Having no information on the error response and sending exactly
>     what you define in:
>
>     https://github.com/ging/fi-ware-idm/wiki/Using-the-FIWARE-LAB-instance
>
>     It Becomes hard to solve it from my side. I've tried giving you
>     every information I have, but If you require more, please ask.
>
>
>     -- 
>     **
>     **
>
>     **
>     *Inline image 1*
>     **
>     **
>     *
>     *Pedro Gonçalves
>     *
>     Research Software Engineer
>     *
>     PLUX - Wireless Biosignals, S.A.*
>
>     *
>     **
>     *
>     *
>     *
>     *Headquarters*
>     *
>     *
>     *
>     **
>     ****
>     **
>     *
>     *
>     Zona Industrial das Corredouras, Lt. 14 - 1º
>     2630-369 Arruda dos Vinhos
>     Portugal
>     *
>     *T*: +351 263 978 572 <tel:%2B351%20263%20978%20572>
>     *
>     *
>     *
>
>     **
>     *
>     ***Lisbon Office*
>     *
>     Av. 5 de Outubro, 70 - 8º
>     1050-059 Lisboa
>     Portugal
>     *T*: +351 211 956 542
>     *T*: +351 211 956 546
>     *F*: +351 211 956 531
>
>     *W*: www.plux.info <http://www.plux.info/>
>
>
>
>
> -- 
> **
> **
>
> **
> *Inline image 1*
> **
> **
> *
> *Pedro Gonçalves
> *
> Research Software Engineer
> *
> PLUX - Wireless Biosignals, S.A.*
>
> *
> **
> *
> *
> *
> *Headquarters*
> *
> *
> *
> **
> ****
> **
> *
> *
> Zona Industrial das Corredouras, Lt. 14 - 1º
> 2630-369 Arruda dos Vinhos
> Portugal
> *
> *T*: +351 263 978 572
> *
> *
> *
>
> **
> *
> ***Lisbon Office*
> *
> Av. 5 de Outubro, 70 - 8º
> 1050-059 Lisboa
> Portugal
> *T*: +351 211 956 542
> *T*: +351 211 956 546
> *F*: +351 211 956 531
>
> *W*: www.plux.info <http://www.plux.info/>
>
>
> _______________________________________________
> Fiware-lab-help mailing list
> Fiware-lab-help at lists.fi-ware.org
> https://lists.fi-ware.org/listinfo/fiware-lab-help


-- 
Sándor Laki
EU FP7 FI-PPP XIFI project,
Wigner Research Centre for Physics,
Hungarian Academy of Sciences
Konkoly Thege Miklós út 29-33.
H-1121, Budapest, Hungary
Cell: +36 70 374 2646
Skype: sandor.laki

XIFI: https://fi-xifi.eu/home.html
FI-PPP: http://www.fi-ppp.eu/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.fiware.org/private/fiware-lab-help/attachments/20150703/509abdea/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 5208 bytes
Desc: not available
URL: <https://lists.fiware.org/private/fiware-lab-help/attachments/20150703/509abdea/attachment.png>


More information about the Fiware-lab-help mailing list

You can get more information about our cookies and privacy policies clicking on the following links: Privacy policy   Cookies policy