xo::oauth::GitHub method get_user_data (public)
<instance of xo::oauth::GitHub> get_user_data [ -token token ] \ [ -required_fields required_fields ]
Defined in packages/xooauth/tcl/authorize-procs.tcl
Get user data based on the temporary code (passed via "-token") provided by GitHub. First, convert the temporary code into an access_token, and use this to get the user data.
- Switches:
- -token (optional)
- -required_fields (optional, defaults to
" {email email} {name name} "
)- Testcases:
- No testcase defined.
Source code: set data [:redeem_code $token] ns_log notice "[self] redeem_code returned keys: [lsort [dict keys $data]]" set result $data if {[dict exists $data access_token]} { # # When we received the access_token, we have no error # so far. # set access_token [dict get $data access_token] #ns_log notice "[self] redeemed form data: $access_token" set result [:get_api_data $access_token] ns_log notice "[self] get_user_data: get_api_data contains error:" [dict exists $result error] if {![dict exists $result error]} { set data [:get_required_fields -claims [dict get $result claims] -mapped_fields { {email email} {name name} }] if {[dict exists $data error]} { set result [dict merge $data $result] } else { set result [dict merge $result [dict get $data fields]] # # We have still to split up "name" into its # components, since GitHub does not provide # the exactly needed fields. Actually, we need # this just for creating a new user_id, so it # might not be always needed. # set first_names [join [lrange [dict get $result name] 0 end-1] " "] set last_name [lindex [dict get $result name] end] dict set result first_names $first_names dict set result last_name $last_name } } } ns_log notice "[self] get_user_data returns $result" return $resultXQL Not present: Generic, PostgreSQL, Oracle