Workday - REST API authentication

92 views Asked by At

I'm trying to use the Workday REST API to fetch & update some workers data. I'm having some difficulties to authenticate to it and the documentation is very poor on information to exploit the API.

I've followed this link, which give guidelines to create OAuth app inside Workday which is a pretty common thing for API authentication.

As I already have an ISU working, I've created an "API Client for Integrations" giving me an Client ID & secret.

The issue is that I manage to get an access_token using these information. Usually this CURL request should work to get my token :

 curl --location '{OAUTH_URL}/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Basic {base64(CLIENT_ID:CLIENT_SECRET)}' \
--data-urlencode 'grant_type=client_credentials'

But this returns :

{
 "error": "Invalid request"
}

Does anyone have any idea of to achieve this ?

Thank you !

EDIT :

I've found a way to generate an access_token using API client for Integrations :

curl --location --request POST 'https://{BASE_URL}/ccx/oauth2/{TENANT}/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=refresh_token' \
--data-urlencode 'client_id=xxx' \
--data-urlencode 'client_secret=xxx' \
--data-urlencode 'refresh_token=xxx'

But I cannot find a way to interact with Workday such as Person API. I'm always getting an error when trying to get /people

1

There are 1 answers

8
Bench Vue On

Try this

CLIENT_ID='***** your Client ID *******'
CLIENT_SECRET='***** your client secret ********'
CLIENT_ID_SECRET=$(echo -n $CLIENT_ID:$CLIENT_SECRET | base64 -w 0)
OAUTH_URL='***** workday auth URL ******'

curl --location --request POST $OAUTH_URL'/token' \
--silent \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Basic '$CLIENT_ID_SECRET \
--data-urlencode "grant_type=client_credentials"

Demo

Ran in the git bash terminal

CLIENT_ID='bHRpY3VsdHwuY29tcH'
CLIENT_SECRET='pQaE-ceDi3nFz'
CLIENT_ID_SECRET=$(echo -n $CLIENT_ID:$CLIENT_SECRET | base64 -w 0)
OAUTH_URL='http://localhost:3000'

curl --location --request POST $OAUTH_URL'/token' \
--silent \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Basic '$CLIENT_ID_SECRET \
--data-urlencode "grant_type=client_credentials"

enter image description here

Generate cURL by Postman

Or can create cURL API by Postman

It convert base64 from client id, client secret

At Authorization tab, to select Basic Auth

The enter username / password by client id and client secret

enter image description here

curl --location --request POST 'http://localhost:3000/token' \
--header 'Authorization: Basic YkhScFkzVnNkSHd1WTI5dGNIOnBRYUUtY2VEaTNuRno='