I'm working on a Drupal 6 module to provide OAuth-based user authentication and registration. I'm already using the OAuth module to authenticate as described on http://oauth.net/core/1.0a/#anchor9. The next step is to create the user account using information provided after authentication using an custom API of the Service Provider.
According to http://drupal.org/node/497612#comment-3047302, I should not use user_external_login_register()
but see the OpenID module for how to properly login an external user.
After studying the OpenID module, here is what I plan to do:
- Try to load an existing user for a authname build from the custom API result using
user_external_load()
. - If a user exists, use
user_external_login()
to log the user in. - If not, pretend the registration form has been submitted (like
openid_authentication()
does) to create a new user account. And redirect to a pre-filled form if any additional information is needed in order for the user to register.
Is this the right way to do it ? Is there another module worth looking at for how to this properly in addition to OpenID ?