Have you implemented OpenMRS? Please participate in the Implementation Site Survey. If you already have, thank you!
Child pages
  • OAuth2 Module - Client REST Controller

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

What this controller does

This REST Controller provides dynamic OAuth client creation and management.

Configuration Options

By default, the controller is mapped at ws/oauth/clientManagement however, users can change this mapping to their liking in the ClientManagementController.java file and change intercept-url mappings in WebModuleApplicationContext.xml

Video Demo

Widget Connector
width560
urlhttps://www.youtube.com/watch?v=y2eSck9JUn0
height315

HOW TO's

  1. Create a new OAuth client

To create a new OAuth Client through the controller you need to make the following request:

...

Code Block
languagejs
titleSample Response (POST)
{
    "id": 42,
    "name": "test2",
    "description": "some desci",
    "clientType": "WEB_APPLICATION",
    "clientIdentifier": "iakbnhm081f8399q94v5bhd01l",
    "clientSecret": "gvkq41p0bsc8au9bqjteue578o",
    "website": "www.abc.com",
    "redirectUri": [
        "www.test.com"
    ],
    "uuid": "72bf7c1d-707d-4bfc-9d07-87ff948b1b7b",
    "creator": "admin",
    "dateCreated": 1503856161000,
    "changedBy": "admin",
    "dateChanged": 1503856161000,
    "voided": false,
    "dateVoided": null,
    "voidReason": null,
    "voidedBy": null,
    "accessTokenValiditySeconds": 600,
    "refreshTokenValiditySeconds": 600,
    "scopes": [
        "read",
        "write"
    ],
    "grantType": [
        "implicit",
        "refresh_token",
        "password",
        "authorization_code"
    ]
}

 

2. View Clients for a Client developer

To view clients for a client developer, you need to make the followig request :

...

Code Block
languagejs
titleSample Response (GET)
[
	{
        "id": 39,
        "name": "finaldemo2",
        "description": "somedesci",
        "clientType": "WEB_APPLICATION",
        "clientIdentifier": "finaldemo2",
        "clientSecret": "odqt3g0hjcnl39hbsi22t4ch4e",
        "website": "www.abc.com",
        "redirectUri": [],
        "uuid": "b072ecce-20f2-4752-8b4a-52c7715d281e",
        "creator": "admin",
        "dateCreated": 1503740189000,
        "changedBy": "admin",
        "dateChanged": 1503740190000,
        "voided": false,
        "dateVoided": null,
        "voidReason": null,
        "voidedBy": null,
        "accessTokenValiditySeconds": 600,
        "refreshTokenValiditySeconds": 600,
        "scopes": [
            "read",
            "write"
        ],
        "grantType": [
            "refresh_token",
            "implicit",
            "password",
            "authorization_code"
        ]
    },
    {
        "id": 40,
        "name": "finaldemo2",
        "description": "somedesci",
        "clientType": "WEB_APPLICATION",
        "clientIdentifier": "finaldemo2",
        "clientSecret": "39mnotbnr85nh3sp8nop2uusua",
        "website": "www.abc.com",
        "redirectUri": [
            "sanatt.me"
        ],
        "uuid": "1f40c348-cae0-4420-b0ba-838c5dd2a4b2",
        "creator": "admin",
        "dateCreated": 1503740890000,
        "changedBy": "admin",
        "dateChanged": 1503740890000,
        "voided": false,
        "dateVoided": null,
        "voidReason": null,
        "voidedBy": null,
        "accessTokenValiditySeconds": 600,
        "refreshTokenValiditySeconds": 600,
        "scopes": [
            "read",
            "write"
        ],
        "grantType": [
            "refresh_token",
            "implicit",
            "password",
            "authorization_code"
        ]
    }
]

 

3. To delete an OAuth Client

Request type : DELETE

Endpoint : /ws/oauth/clientManagement

...

Sample Response : "Client deleted"

4. To update the details of an OAuth Client

This request will make changes to the fields as specified in the request and return an updated version of the client

...