0

So, I'm working on an implementation where users will be redirected to a specific path on a Drupal 7 site with query parameters appended to the URL in an Oauth2 scenario (e.g. www.mysite.com/mypath&code&scope) which the D7 should process and respond to. How does one specify within a custom module to run the code a particular path? Would this be achieved through a code block?

11
  • 1
    Which module are you talking about? Feb 6, 2018 at 14:02
  • 1
    It's a custom module @Clive I want to run a series of functions in the background. It's an Oauth2 scenario where I want to get the response, request a token, and log the user in in the background.
    – nizz0k
    Feb 6, 2018 at 14:08
  • 1
    @brotherpere a custom one
    – nizz0k
    Feb 6, 2018 at 14:15
  • 1
    @brotherpere no, sorry, I don't know the best way to articulate this. Users will be redirected to my site as part of an Oauth2 scenario, based on the query parameters appended to the redirect URL, I need to send a post request to get an auth token, submit the auth token for user data, and use the user data to log the user in. So, I don't need to redirect the users anywhere, I want them to end up on that page, but I need to run the authorization steps before they can actually access the site.
    – nizz0k
    Feb 6, 2018 at 14:25
  • 1
    @Clive, sorry, I'm having trouble articulating this: by the "background" I mean without the users direct involvement. I'm trying to run the authorization and login steps as a part of an oauth flow. I want to respond to the provided query parameters in the redirect url, so my assumption is that I need to run a script on the path of the redirect url. As far as the user knows, they've just agreed to authorize my application. Submitting their creds redirects to my path with a code, I assume I need to run the rest of my auth/login process code at the path where the query params are provided. or no?
    – nizz0k
    Feb 6, 2018 at 14:33

1 Answer 1

1

You can use OAuth2 Authentication. Some details about it, from its project page:

... allows users to log into your Drupal site authenticating against a remote identity provider (IDP) via OAuth2.

That is, if a user's credentials can be used to retrieve a valid access token, he/she will be logged into the site with those credentials and the token will be added to his/her session. If the user doesn't exist yet, it will be created.

6
  • I'll look at this again, but my initial experiments didn't produce the results I wanted.
    – nizz0k
    Feb 6, 2018 at 14:48
  • Keep me posted with the problem you encounter. Here to help. Feb 6, 2018 at 14:51
  • 1
    Appreciate it! I won't be able to dive in a for a few hours, I'm slacking at the day job.
    – nizz0k
    Feb 6, 2018 at 14:52
  • Hey, sorry for the late response. This solves part of my problem, but does quite offer the functionality I need. It seems that by default the Oauth2 Auth module checks every user against the oauth server, whereas I want to have this functionality for a subset of users. The current config also has the user and pass form, which uses the user-pass flow which I want to avoid. I hope this module will help me sort out of the login and management of the user while their signed in. Fingers crossed. I'm currently looking at user_external_login_register
    – nizz0k
    Feb 25, 2018 at 15:22
  • Was this the answer to your problem? Mar 4, 2018 at 11:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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