3

Learn How to Extract a List of Active SAP Concur Users Using the User Identity a...

 1 year ago
source link: https://blogs.sap.com/2023/01/03/learn-how-to-extract-a-list-of-active-sap-concur-users-using-the-user-identity-and-provisioning-api/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
January 3, 2023 3 minute read

Learn How to Extract a List of Active SAP Concur Users Using the User Identity and Provisioning API

In this blog, I will demonstrate how to use the SAP Concur User Identity and Provisioning API to retrieve a list of active users.

https://developer.concur.com/api-reference/profile/v4.identity.html

https://developer.concur.com/api-reference/user-provisioning/v4.user-provisioning.html

There are a few steps we need to follow, such as obtaining an access token and using it to retrieve the list of active users and their assigned roles.

Obtain the Access Token

To access the Authentication Admin page in the Concur portal, log in to https://us2.concursolutions.com and go to Administration > Company > Authentication Admin.

sap1.png

Select OAuth 2.0 Application Management.

1Vr7yz29n6WLDtEw2o0dzYA.png

To proceed, either select an existing Client ID or click on “Create New App” to create a new one.

sap3.png

It is important to verify that the necessary permissions (called “scopes”) are in place.

Here is the list of scopes that I used.

sap4.png

To create the access token, go back to the Authentication Administration page and click on “Company Request Token”.

sap5.png

Enter the Client ID in the App ID field and click on “Submit”.

Screenshot-2023-01-03-at-6.33.22-PM.png

After submitting, you will receive the Company UUID and Company Request Token. It is important to note that the request token has a lifespan of 24 hours and must be exchanged for a refresh token and access token by the application owner before it expires.

sap8.png

To refresh the token using Postman, enter the following information:

  • client_id: Client ID
  • client_secret: Client Secret
  • grant_type: password
  • username: Company UUID
  • password: Company Request Token
  • credtype: authtoken
  • URL: https://us2.api.concursolutions.com/oauth2/v0/token
1*LyDNuKxL1BvWwry0MRWfxQ.png

You will get the company JWT or access_token which has the token lifetime of 1 hour and can be used to call Concur APIs.

The refresh_token has a validity of six months. For more information on how to use and refresh it, please refer to the documentation.

Retrieve the list of Active Users

To obtain a list of active users, you can use this API endpoint.

https://us2.api.concursolutions.com/users/?offset=0&limit=100&isactive=true

1*idrjKLLh4eRCFgY06BAeFQ.png

In the Authorisation tab, choose Bearer token and enter the access_token (company JWT token) from the previous step.

1*-uWMaFo9DjtnXEKk2ZgUTw.png

While you may be able to use other endpoints, you may encounter a 504 gateway timeout error frequently.

https://us.api.concursolutions.com/profile/identity/v4/Users?count=100&startIndex=2

1*s-11cG1skn9a-DzWnaRCfg.png

Retrieve the Assigned Role

To obtain the assigned role for a user, you will need to first retrieve the user’s ID using the Get API.

https://us2.api.concursolutions.com/profile/identity/v4/Users?filter=userName eq “<userid>”

1*3ExhJNGKyCOO-iz9frfKsA.png

From the above screenshot the user ID is adb2df64–008e-41d0–8e41–0424068a875a. Use this API to get the list of roles assigned.

https://us2.api.concursolutions.com/profile/spend/v4/Users/<user_id>

1*W5ye9d0LP4L4MzBlp7kRMw.png

If a role has been assigned to the user, it will be visible in the entity urn:ietf:params:scim:schemas:extension:spend:2.0:Role.

I created a NodeJS script that retrieves a list of active users and stores it in a JSON file in order to automate this process.

https://github.com/ferrygun/sapconcur_extract_active_user


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK