I’m trying to make a 3rd party desktop app for Nextcloud tasks - I’m currently trying to authenticate the user with Nextcloud.
I’m following the directions at Login-Flow v2 to get oAuth working. My project is plagued with CORS errors but that’s besides the point - I’m launching Chrome with --disable-web-security which gets me past CORS issues.
The real issue is when sending the POST request with the token to the polling endpoint (https://cloud.example.com/login/v2/poll) my server is returning a internal error 500
Could anyone point me in the right direction to diagnose this issue?
This should not happen. I did it multiple times with curl and it was never a problem. It’s there any clue in the log of nextcloud?
Apart from that does it work with the curl approach as documented? I am fearing, the browser might sent additional information like cookies that collide with the login flow. If curl is not working for you, i can try it on my machine later on. What core version you are working on, ATM?
How do I access the nextcloud log from an SSH session? I’m away from the server and only have terminal access.
Version 24.0.5 btw
Got it logging! This was the output when calling the polling endpoint:
OC\Core\Controller\ClientFlowLoginV2Controller::poll():
Argument #1 ($token) must be of type string,
null given, called in
/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php
on line 225 in file
'/var/www/nextcloud/core/Controller/ClientFlowLoginV2Controller.php'
line 95 at
lib/private/AppFramework/Http/Dispatcher.php
line 165
0. .../App.php line 172
OC\AppFramework\Http\Dispatcher->dispatch(
)
1. .../Router.php line 298
OC\AppFramework\App::main(
)
2. .../base.php line 1030
OC\Route\Router->match(
)
3. index.php line 36
OC::handleRequest(
)
Caused by TypeError:
OC\Core\Controller\ClientFlowLoginV2Controller::poll():
Argument #1 ($token) must be of type string,
null given, called in
/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php
on line 225 at
core/Controller/ClientFlowLoginV2Controller.php
line 95
0. .../Dispatcher.php line 225
OC\Core\Controller\ClientFlowLoginV2Controller->poll(
)
1. .../Dispatcher.php line 133
OC\AppFramework\Http\Dispatcher->executeController(
)
2. .../App.php line 172
OC\AppFramework\Http\Dispatcher->dispatch(
)
3. .../Router.php line 298
OC\AppFramework\App::main(
)
4. .../base.php line 1030
OC\Route\Router->match(
)
5. index.php line 36
OC::handleRequest(
)```
seems to be an error with how I'm sending the data in my angular HttpModule...
The problem must be with the way I’m forming the POST request in Angular…
this.http.post<AuthResponse>(
url,
"token=" + token,
{ responseType: 'json', headers: this.headers }
)
but I’m using an HttpInterceptor and the request it’s interceping’s body IS a string so I don’t understand why it’s erroring?
I am sorry, with Angular I have zero experience. Are you sure that the token
is in fact a valid variable with valid content in that context? From the NC error, I would guess not so but this is really hard for me. What device are you using in this case? If it’s in the browser, you might be able to have a look at the dev tools and what the actual request is. If not, you could use a network sniffer on an unencrypted connection to grasp what is going on. A real angular dev might be of more use than me, though…
it was a problem with how I was making the http request. the data had to be send as a parameter, not as req body
thanks for your help man!
1 Like
If you have SSH access to the server, a good command to have a look at the logs is
tail -fn1 /path/to/nextcloud/data/nextcloud.log | jq
You can drop the | jq
to have the raw outputs but these might quickly get overwhelmed as the JSON are stored compactly.
You can also add a parameter to jq
to filter the logs or extract certain entries. See also DevDocs and jq Manual.
Well in my case I was running NextcloudPi and the command to watch the log for that is:
sudo -u www-data php occ log:watch
not sure if the command you posted works with NCP but I just wanted to post that for any future users!
The command tail
is part of every linux installation. Should work with pi as well.
1 Like