Drupal Answers is a question and answer site for Drupal developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So with the current Drupal 7's OpenID module, one must click on the "OpenID" on the main page, which the user then enter the url of the OpenID provider to link up to. Assuming I know exactly what provider I want to use (my university's), there some way I can make it such that as soon as a user visits the homepage, or any part of my drupal site, the first thing it does is authenticates with that specific provider url before it even shows the page?

The reason being is I want people within the university network to be able to go to the site and automatically see who they are without having them perform that extra step of clicking on an "openid" button. Much like a single-sign-on solution.

share|improve this question

You must create a custom module to generate a page "/login" that start OpenID authenticate.

Create a module with this code :

 * Implements hook_menu().
function mymodule_menu() {

  $items['login'] = array(
    'title' => 'OpenID Login',
    'page callback' => 'openid_login',
    'access callback' => 'user_is_anonymous',
    'type' => MENU_CALLBACK,

  return $items;

 * Menu callback; start openid authenticate
function mymodule_login() {

  $return_to = url('openid/authenticate', array('absolute' => TRUE, 'query' => array('destination' => 'user')));

  openid_begin("https://www.myopenid.com/", $return_to, array());

The example works with the myopenid.com provider. Go to "/login" on your website to log in.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.