oauth2 - vkontakte integration => invalidsesskey

oauth2 - vkontakte integration => invalidsesskey

by C P -
Number of replies: 3
[post split in several messages to avoid being flagged as spam]

[http : //  is replaced with http ] 


I have the following situation:

moodle 3.4.2 (centos/php7/mysql) - but started to manifest since moodle 3.3  - which embeded oauth2 and replaced google_oauth2 plugin

Site administration ->  server -> oauth2 -> set a custom service

add  vkontakte (app_id / secret number) 

Added following endpoints for VK: 

authorization_endpoint https://oauth.vk.com/authorize  

token_endpoint https://oauth.vk.com/access_token  



Average of ratings: -
In reply to C P

Re: oauth2 - vkontakte integration => invalidsesskey

by C P -

userinfo_endpoint https://api.vk.com/method/users.get  also tried with  https://vk.com/dev/users.get

I have it "displayed on 1st page" and email confirmation - go on Vkontakte button and 

i get the oauth prompt from 


oauth.vk.com/authorize?client_id=MYAPP_ID&response_type=code&redirect_uri=http  MYSITE%2Fmoodle%2Fadmin

%2Foauth2callback.php&state=%2Fauth%2Foauth2%2Flogin.php%3Fwantsurl%3Dhttp FMYSITEAGAIN%252Fmoodle%

252F%26sesskey%3DYNXrCJEqXR%26id%3D4&scope=openid%20profile%20email%20&access_type=offline&prompt=consent


I get a page/frame with following content: 

The application MYAPP/SITE is requesting access to your account.

Access to General Information

The application requires access to your profile info

Email address

i***@MYSITE (Deny)

+ 2 buttons : Cancel / Allow 

Press "allow" and 


Your session has most likely timed out. Please log in again.

More information about this error


×Debug info: 

Error code: invalidsesskey

×Stack trace:

line 482 of /lib/setuplib.php: moodle_exception thrown

line 56 of /admin/oauth2callback.php: call to print_error()


I've tried with sessions stored on disk (moodledata_dir/sessions)  or in DB - result is the same





In reply to C P

Re: oauth2 - vkontakte integration => invalidsesskey

by C P -

[last part - phew ]


in Vkontakte settings I have the following: 


Install Application: Optional

Open API: Enabled

Open API: 

Site address:  http://MYSITE/moodle

Website focus: Education

Base domain: MYSITE


Authorized redirect URI:  http://MYSITE/moodle/admin/oauth2callback.php


Simply  - can't figure out what is going on


Thanks in advance for helpin' 


In reply to C P

Re: oauth2 - vkontakte integration => invalidsesskey

by C P -

collected the logs 


[Wed Mar 21 18:53:35.969970 2018] [:error] [pid 4877] [client 176.127.24.146:64990] Default exception handler: Your session has most likely timed out. Please log in again. Debug: \nError code: invalidsesskey\n* line 482 of /lib/setuplib.php: moodle_exception thrown\n* line 56 of /admin/oauth2callback.php: call to print_error()\n

[Wed Mar 21 18:54:00.667945 2018] [:error] [pid 32163] [client 176.127.24.146:64997] Default exception handler: Your session has most likely timed out. Please log in again. Debug: \nError code: invalidsesskey\n* line 482 of /lib/setuplib.php: moodle_exception thrown\n* line 56 of /admin/oauth2callback.php: call to print_error()\n, referer: http://MYSITE/moodle/login/index.php

[Wed Mar 21 18:54:07.064678 2018] [:error] [pid 5591] [client 176.127.24.146:64999] Default exception handler: Sorry, the requested file could not be found Debug: \nError code: filenotfound\n* line 482 of /lib/setuplib.php: moodle_exception thrown\n* line 1885 of /lib/filelib.php: call to print_error()\n* line 2061 of /lib/outputlib.php: call to send_file_not_found()\n* line 59 of /theme/lambda/lib.php: call to theme_config->setting_file_serve()\n* line 4803 of /lib/filelib.php: call to theme_lambda_pluginfile()\n* line 40 of /pluginfile.php: call to file_pluginfile()\n, referer: http://MYSITE/moodle/?

[Wed Mar 21 18:54:15.236204 2018] [:error] [pid 3025] [client 176.127.24.146:65001] Default exception handler: Sorry, the requested file could not be found Debug: \nError code: filenotfound\n* line 482 of /lib/setuplib.php: moodle_exception thrown\n* line 1885 of /lib/filelib.php: call to print_error()\n* line 2061 of /lib/outputlib.php: call to send_file_not_found()\n* line 59 of /theme/lambda/lib.php: call to theme_config->setting_file_serve()\n* line 4803 of /lib/filelib.php: call to theme_lambda_pluginfile()\n* line 40 of /pluginfile.php: call to file_pluginfile()\n, referer: http://MYSITE/moodle/?

[Wed Mar 21 18:54:15.624502 2018] [:error] [pid 5591] [client 176.127.24.146:64999] Default exception handler: Sorry, the requested file could not be found Debug: \nError code: filenotfound\n* line 482 of /lib/setuplib.php: moodle_exception thrown\n* line 1885 of /lib/filelib.php: call to print_error()\n* line 2061 of /lib/outputlib.php: call to send_file_not_found()\n* line 61 of /theme/lambda/lib.php: call to theme_config->setting_file_serve()\n* line 4803 of /lib/filelib.php: call to theme_lambda_pluginfile()\n* line 40 of /pluginfile.php: call to file_pluginfile()\n, referer: http://MYSITE/moodle/?

but the files are there:

/var/www/html/moodle/theme/lambda 

-rw-r--r-- 1 apache apache 6.4K Mar 21 18:52 config.php

-rw-r--r-- 1 apache apache  31K Mar 21 18:52 lib.php

-rw-r--r-- 1 apache apache  970 Mar 21 18:52 renderers.php

-rw-r--r-- 1 apache apache  46K Mar 21 18:52 settings.php

-rw-r--r-- 1 apache apache 1.3K Mar 21 18:52 version.php

(ignore timestamp - i've just updated them into a pathetic attempt)