I have a project in github read_file , but when I try to use the oauth2_example to try to authenticate a user in oauth2 as exemplified in the ouath2 site generates the following error:
=ERROR REPORT==== 1-Dec-2018::10:44:24 ===
Ranch listener http, connection process <0.174.0>, stream 1 had its request process <0.175.0> exit with reason undef and stacktrace [{upgrade,upgrade,[protocol,#{dispatch => [{'_',[],[{[<<"correios">>],[],foo_correios_handler,[]},{[<<"home">>],[],foo_start_handler,[]},{[<<"resource">>],[],oauth2_barramento_resource,[]},{[<<"permission">>],[],foo_permission_handler,[]},{[<<"sample">>],[],foo_sample_handler,[]},{[<<"auth">>],[],oauth2_barramento_auth,[]}]}],handler => oauth2_barramento_auth,handler_opts => []},oauth2_barramento_auth,cowboy_rest],[]},{cowboy_stream_h,execute,3,[{file,"src/cowboy_stream_h.erl"},{line,293}]},{cowboy_stream_h,request_process,3,[{file,"src/cowboy_stream_h.erl"},{line,271}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]
The code that authenticates the user follows:
init(_Transport, _Req) ->
{ok, auth_form} = erlydtl:compile(filename:join(["priv", "static", "auth_form.dtl"]),
auth_form,[{out_dir,"priv"}]),
{upgrade, protocol, cowboy_rest}.
To replicate the error, just download the read_file project and follow these steps:
1 - use command rebar get-deps
2 - use command rebar compile
3 - use command erl -pa ebin / -pa deps / * / ebin /
4 - inside erl terminal use foo: start ().
5 - On the console enter the command read_catalog: read_all_files_Folder ().
6 - oauth2_backbackbar: add_user ( "bob"> ).
7 - curl -v -X POST link \ -d "grant_type = password & username = bob & password = luv_alice & scope = yourbase"
After these steps the error happens and I do not know why.