public function print_login() {

        $reqtoken = $this->flickr->request_token();
        $this->flickr->set_request_token_secret(['caller' => 'repository_flickr'], $reqtoken['oauth_token_secret']);

        // Even when the Flick auth docs states the "perms" argument is
        // optional, it does not work without it.
        $authurl = new moodle_url($reqtoken['authorize_url'], array('perms' => 'read'));

        if ($this->options['ajax']) {
            return [
                'login' => [
                    [
                        'type' => 'popup',
                        'url' => $authurl->out(false),
                    ],
                ],
            ];

        } else {
            echo '<a target="_blank" href="'.$authurl->out().'">'.get_string('login', 'repository').'</a>';
        }
    }