Account Information¶
The account methods in the MOI SDK operate on the current MOI Catalog Service user. They can read and update the caller’s profile, change the password, and read or refresh the caller’s API key. A Catalog Service user is not the same thing as a registered account in the unified account center or a MatrixOne database user.
Available methods¶
Operation |
Python |
Go |
|---|---|---|
Read the caller and effective privileges |
|
|
Update phone, email, and description |
|
|
Change the caller’s password |
|
|
Read the caller’s API key |
|
|
Refresh the caller’s API key |
|
|
get_my_info and GetMyInfo return the user profile, global privilege codes,
and object-level privileges. Python returns a decoded dictionary. Go returns a
UserMeInfoResponse containing UserInfo, AuthorityCodeList, and
ObjAuthorityCodeList.
Read the current user¶
import os
from moi import RawClient
client = RawClient(
base_url=os.environ["MOI_BASE_URL"],
api_key=os.environ["MOI_API_KEY"],
)
me = client.get_my_info()
user = me["user_info"]
print(user["id"], user["name"], user["status"])
print("global privileges:", me["authority_code_list"])
package main
import (
"context"
"fmt"
"log"
"os"
sdk "github.com/matrixorigin/moi-go-sdk"
)
func main() {
client, err := sdk.NewRawClient(
os.Getenv("MOI_BASE_URL"),
os.Getenv("MOI_API_KEY"),
)
if err != nil {
log.Fatal(err)
}
me, err := client.GetMyInfo(context.Background())
if err != nil {
log.Fatal(err)
}
fmt.Println(me.UserInfo.ID, me.UserInfo.Name, me.UserInfo.Status)
fmt.Println("global privileges:", me.AuthorityCodeList)
}
Production code should also check that UserInfo is not nil before
dereferencing it. Use the privilege codes returned by the service for
authorization decisions; do not infer privileges from a user name or a visible
console entry.
Update the profile¶
The self-service profile request exposes only the phone, email, and description fields:
client.update_my_info(
{
"phone": "13800000000",
"email": "developer@example.com",
"description": "Data platform integration",
}
)
A missing request is not valid: Python raises ErrNilRequest for None, and
the Go methods require a non-nil request pointer. The service still validates
field formats and whether an empty value is accepted. Call get_my_info()
again if the application needs to confirm the stored result.
API key safety¶
RawClient requires a base URL and API key and automatically places the key in
the moi-key request header. Do not apply the Genesis
Authorization: Bearer convention to this client.
Refreshing an API key is a credential-rotation operation. Both SDKs expose a
refresh method, but its response type does not contain the new key. The old-key
invalidation point and secure delivery flow therefore depend on the target
deployment. Test and document that flow before production use, and never print
the full response from get_my_api_key() in application logs.
For administrative user operations, see Member Management. For the privilege response model, see Permissions and Audit Logs. The current signatures are maintained in the Python SDK and Go SDK repositories.