次のページを参考にしました。
Command line
プログラム
get_name.sh
ACCESS_TOKEN="glpat-********"
#
URL="https://gitlab.com/api/graphql"
#
curl -H "Authorization: Bearer "${ACCESS_TOKEN} \
-H "Content-Type: application/json" \
-X POST -d@query.json ${URL}
query.json
{"query": "query {currentUser {name location username webUrl}}"}
実行結果
$ ./get_name.sh | jq
{
"data": {
"currentUser": {
"name": "Uchida Masatomo",
"location": "栃木県",
"username": "ekzemplaro",
"webUrl": "https://gitlab.com/ekzemplaro"
}
}
}