See Release Notes
Long Term Support Release
Differences Between: [Versions 39 and 310] [Versions 39 and 311] [Versions 39 and 400] [Versions 39 and 401] [Versions 39 and 402] [Versions 39 and 403]
Configurable oauth2 client class.
Copyright: | 2017 Damyon Wiese |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 359 lines (12 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
client:: (12 methods):
__construct()
auth_url()
get_issuer()
get_additional_login_parameters()
get_login_scopes()
token_url()
get_tokenname()
store_token()
get_stored_token()
get_userinfo_mapping()
upgrade_refresh_token()
get_userinfo()
__construct(issuer $issuer, $returnurl, $scopesrequired, $system = false) X-Ref |
Constructor. param: issuer $issuer param: moodle_url|null $returnurl param: string $scopesrequired param: boolean $system |
auth_url() X-Ref |
Returns the auth url for OAuth 2.0 request return: string the auth url |
get_issuer() X-Ref |
Get the oauth2 issuer for this client. return: \core\oauth2\issuer Issuer |
get_additional_login_parameters() X-Ref |
Override to append additional params to a authentication request. return: array (name value pairs). |
get_login_scopes() X-Ref |
Override to change the scopes requested with an authentiction request. return: string |
token_url() X-Ref |
Returns the token url for OAuth 2.0 request We are overriding the parent function so we get this from the configured endpoint. return: string the auth url |
get_tokenname() X-Ref |
We want a unique key for each issuer / and a different key for system vs user oauth. return: string The unique key for the session value. |
store_token($token) X-Ref |
Store a token between requests. Uses session named by get_tokenname for user account tokens and a database record for system account tokens. param: stdClass|null $token token object to store or null to clear |
get_stored_token() X-Ref |
Retrieve a stored token from session (user accounts) or database (system accounts). return: stdClass|null token object |
get_userinfo_mapping() X-Ref |
Get a list of the mapping user fields in an associative array. return: array |
upgrade_refresh_token(system_account $systemaccount) X-Ref |
Upgrade a refresh token from oauth 2.0 to an access token param: \core\oauth2\system_account $systemaccount return: boolean true if token is upgraded succesfully |
get_userinfo() X-Ref |
Fetch the user info from the user info endpoint and map all the fields back into moodle fields. return: array|false Moodle user fields for the logged in user (or false if request failed) |