My Oracle Support Banner

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

Last updated on FEBRUARY 18, 2021

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
https://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.

Registered Client and Approved Request, Received Auth Code
==========================================================
https://<DOMAINNAME>/?code=<CODE>&state=<STATE_VALUE>


Swapped Code for Token
======================
curl -i -d "grant_type=authorization_code&code=<CODE>"
--user <USERID>
https://<DOMAINNAME>:port/apex/oauth2/token

Result
======
HTTP/1.1 200 OK
Date: Tue, 05 Aug 2014 01:07:45 GMT
Server: Oracle-Application-Server-11g
Set-Cookie:
OAMAuthnCookie_sdsservice-<DOMAINNAME>=<COOKIE_ID>
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":"<TOKEN>.","token_type":"bearer","expires_in":3600,"refresh_token":"<REFRESHTOKEN>"}

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

curl -i -d
"grant_type=refresh_token&refresh_token=<REFRESH_TOKEN>" --user
<USERID>
https://<DOMAINNAME>:port/apex/oauth2/token

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

Cause

To view full details, sign in with your My Oracle Support account.

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


In this Document
Symptoms
Cause
Solution
References


My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.