Hi, I'am trying to call /api/token with a master token in api_keys and identification and password. But when I try to call the api, I get the error that you can view above.
I'am trying to log in inside flarum from an external login's form in another website.
This is my code:
getToken method parameeters(username, password)
$data = [
'identification' => $username,
'password' => $password,
'lifetime' => $this->getLifetimeSeconds(),
];
$response = $this->sendRequest('/api/token', $data);
sendRequest method parameters(path, data)
$options = [
http => [
' header' => 'Authorization: Token '<mytoken>' ; userId=<admin_user_id>,
'method' => $method(POST),
'content' => http_build_query($data),
'ignore_errors' => true
]
];
$context = stream_context_create($options);
$result = file_get_contents(<my_url_to_flarum> . $path, false, $context);
return json_decode($result, true);