invalid_acess_token on bearer generation

This space is made available to users of Open Patent Services (OPS) web-service and now also to users of EPO’s bulk data subscription products such as 14. EPO worldwide bibliographic database (DOCDB), 14.11 EPO worldwide legal status database (INPADOC), 14.12 EP full text data, 14.1 EP bibliographic data (EBD)and more.

Users can ask each other questions, exchange experiences and solutions, post ideas. The moderator will use this space to announce changes or other relevant information.
Post Reply

WildCodeSchoolOrleans
Posts: 1
Joined: Wed Jan 26, 2022 9:53 am

invalid_acess_token on bearer generation

Post by WildCodeSchoolOrleans » Wed Jan 26, 2022 10:02 am

Hello OPS Team,

I have an issue on generating my bearer token, in java. I've got this:

Code: Select all

09:41:19.410 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "<error><code>400</code><message>invalid_access_token</message><description>Access token is invalid</description>[\n]
while i'm trying to get my bearer.

Here is the code i use:

Code: Select all

    public static String getBearerToken() throws URISyntaxException, IOException {
        String basicAuth = getBase64(consummerKey, consummerSecretKey);
        String bearerToken = null;

        HttpClient httpClient = HttpClients.custom()
                .setDefaultRequestConfig(RequestConfig.custom()
                        .setCookieSpec(CookieSpecs.STANDARD).build())
                .build();

        URIBuilder uriBuilder = new URIBuilder("https://ops.epo.org/3.2/acesstoken");
        ArrayList<NameValuePair> queryParameters;
        queryParameters = new ArrayList<>();
        queryParameters.add(new BasicNameValuePair("grant_type", "client_credentials"));
        uriBuilder.addParameters(queryParameters);

        HttpPost httpPost = new HttpPost(uriBuilder.build());
        httpPost.setHeader("Authorization", basicAuth);
        httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded");

        HttpResponse response = httpClient.execute(httpPost);
        HttpEntity entity = response.getEntity();

        if (null != entity) {
            bearerToken = EntityUtils.toString(entity, "UTF-8");
        }
        return bearerToken;
    }
By advance, many thanks for your help.

Raphaël


EPO / OPS Support
Posts: 1294
Joined: Thu Feb 22, 2007 5:32 pm

Re: invalid_acess_token on bearer generation

Post by EPO / OPS Support » Wed Jan 26, 2022 1:56 pm

Hi

Maybe some user can give you advice. I can only point you to OPS documentation under "Further Information": https://www.epo.org/searching-for-paten ... s/ops.html where we give some information about token

Let see if some Java skilled developer reading this can help you

Regards,
Vesna for OPS support


Post Reply