private String token ( final String code ) throws IOException { return new JdkRequest ( new Href ( this . gauth ) . path ( "o" ) . path ( "oauth2" ) . path ( "token" ) . toString ( ) ) . body ( ) . formParam ( "client_id" , this . app ) . formParam ( "redirect_uri" , this . redir ) . formParam ( "client_secret" , this . key ) . formParam ( "grant_type" , "authorization_code" ) . formParam ( PsGoogle . CODE , code ) . back ( ) . header ( "Content-Type" , "application/x-www-form-urlencoded" ) . method ( com . jcabi . http . Request . POST ) . fetch ( ) . as ( RestResponse . class ) . assertStatus ( HttpURLConnection . HTTP_OK ) . as ( JsonResponse . class ) . json ( ) . readObject ( ) . getString ( PsGoogle . ACCESS_TOKEN ) ; }
Retrieve Google access token .