Extend Auth Token For Restful Services Using "curl" Command Fails With Error: {"error":"invalid_grant"} (Doc ID 1916551.1)

Last updated on MARCH 08, 2017

Applies to:

Oracle REST Data Services - Version 2.0.7 and later
Information in this document applies to any platform.

Symptoms

On : 2.0.7 & 2.0.8 versions.

Extend Auth Token For Restful Services Using "curl" Command  Fails With Error: {"error":"invalid_grant"}


While trying to extend the OAUTH token using refresh_token and curl, it fails with the error {"error":"invalid_grant"}.

The following document is followed to implement this:
ORDS developer guide
http://www.oracle.com/technetwork/developer-tools/rest-data-services/documentation/listener-dev-guide-1979546.html

The Auth code is exchanged for a token but an error occurs when trying
to extend the token with the refresh token.

Details of Issue below. This issue also happens in local ORDS
environment for the customer.

Registered Client and Approved Request, Received Auth Code
==========================================================
https://www.google.com/?code=mkqNl8wEySuqstZDehW-9g..&state=800c188b-9d4b-a77a-4167-ee5bba973b38&gws_rd=ssl


Swapped Code for Token
======================
curl -i -d "grant_type=authorization_code&code=mkqNl8wEySuqstZDehW-9g.."
--user bWjUoDP5iLJVW1pz3pj8yg..:nW7FJrU_RQubf4AkyVF9-A..
https://server:port/apex/oauth2/token

Result
======
HTTP/1.1 200 OK
Date: Tue, 05 Aug 2014 01:07:45 GMT
Server: Oracle-Application-Server-11g

httponly; secure; path=/
X-Powered-By: Servlet/2.5 JSP/2.1
Vary: Accept-Encoding
Transfer-Encoding: chunked
Content-Type: application/json
Content-Language: en

{"access_token":"IJZ2WN790Z0wsrq3Nv-tkA..","token_type":"bearer","expires_in":3600,"refresh_token":"O4JKUstAJTGaTvX2FfYeJQ.."}

Attempt to Extend Token
=======================

curl -i -d
"grant_type=refresh_token&refresh_token=O4JKUstAJTGaTvX2FfYeJQ.." --user
bWjUoDP5iLJVW1pz3pj8yg..:nW7FJrU_RQubf4AkyVF9-A..
https://server:port/apex/oauth2/token

Error
--------
{"error":"invalid_grant"}

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms