Learn how to perform common actions from the examples
User Management
In this section of the documentation, we've provided detailed guides showing examples of common user management actions you can perform using the Admin API. Click on any of the links below to view the corresponding guide:
Authgear Admin GraphQL API supports searching user by keywords. Keywords include email, phone number, username, SSO subject id and standard attributes.
Search users by email
You can use the user search query to search user by email and obtains the user details.
In the following example, the project wants to search the user by email and check if they haven't set up the TOTP authenticator.
You can adjust the fields in the query based on your needs. To explore more supporting fields, you can try it out via the GraphiQL tool.
The query has a maximum limit of 20, pagination parameters should be provided to obtain all the results. See detail.
Make sure to copy the original standard attributes as any attributes that are missing in the payload will be deleted. Next, change the values for attributes that you want to update.
The query:
mutation ($userID: ID!, $standardAttributes: UserStandardAttributes!) {
updateUser(input: {userID: $userID, standardAttributes: $standardAttributes}) {
user {
id
standardAttributes
updatedAt
}
}
}
The variables:
{
"userID": "<BASE64URL_ENCODED_USER_NODE_ID>",
"standardAttributes": {
/* Include all the original standard attributes from the previous response */
/* and change the attributes that you want to update */
/* The attributes that are missing in the payload will be deleted */
}
}
Authgear allows your server to update the user's picture via the Admin APIs.
Overview
To update the user's picture:
Make a GET request to /_api/admin/images/upload to obtain the pre-signed upload url.
Make a POST request to the pre-signed upload url to upload the image file. This call returns the result url once the upload is finished.
Call the Admin GraphQL API /_api/admin/graphql to update the user's standard attributes. Update the picture attribute with the result url returned by the previous call.
API Details
Obtain the per-signed upload url
Make a GET request to /_api/admin/images/upload to obtain the pre-signed upload url.
The call will look like this:
GET /_api/admin/images/upload HTTP/1.1
Host: <YOUR_APP>.authgear.cloud
Authorization: Bearer <JWT>
Upload the picture to the pre-signed upload url. We recommend you to pre-process the image before uploading. The image should be cropped into square and should be less than 10 MB.
Upload the file with FormData and the field name is file. You can construct the multipart/form-data request by most HTTP libraries.
The call returns the result url once the upload completed, the url is in format of authgearimages:///APP_ID/OBJECT_ID:
{
"result": {
"url": "authgearimages:///..."
}
}
Update user's picture in the standard attributes
Follow the doc of Update user's standard attributes to update the user's picture attribute. Replace the attribute with the new picture url (e.g. authgearimages:///...) obtained by the previous upload.
Generate OTP code
Authgear Admin GraphQL API supports generating OTP code on behalf of end-user when they asks for support.