#!/bin/bash # employees='./usrlist' # usrlist: email_firstname_lastname_middlename # OAuth_Token # # https://tech.yandex.ru/oauth/doc/dg/tasks/get-oauth-token-docpage/ TOKEN="bash!bash!bash!bash!bash!bash!bash!bash!" # PASS="superstrongpasswordforyou" # for i in $( cat $employees ); do value=($(echo $i | tr "_" " ")) # email="${value[0]}" firstname="${value[1]}" lastname="${value[2]}" middlename="${value[3]}" # curl -i -X POST -H 'Content-type: application/json' -d '{"department_id": 1, "password": "'$PASS'", "nickname": "'$email'", "name": {"first": "'$firstname'", "last": "'$lastname'", "middle": "'$middlename'"}}' -H "Authorization: OAuth $TOKEN" 'https://api.directory.yandex.net/v6/users/' | grep HTTP done
curl -i -X POST -H 'Content-type: application/json' -d '{"department_id": 1, "password": "'$PASS'", "nickname": "'$email'", "name": {"first": "'$firstname'", "last": "'$lastname'", "middle": "'$middlename'"}}' -H "Authorization: OAuth $TOKEN" 'https://api.directory.yandex.net/v6/users/'
"department_id": 1
, we are interested in the number, "1", this is the default department "All employees". When you create a new department (regardless of the name), it will be "2", respectively, and subsequent ones. https://oauth.yandex.ru/authorize?response_type=token&client_id=< >
Source: https://habr.com/ru/post/448036/
All Articles