- Issue created by @jerrac
- π¦πΊAustralia lykyd
Hello,
To be able to map your custom fields to drupal fields you will have to create custom claims.
Create a custom module and in its .module file (ex : yourmodule.module) you have to implement the g2f_account_openid_connect_claims_alter* Implements hook_openid_connect_userinfo_claim_alter() */ function yourmodule_openid_connect_claims_alter(array &$claims) { // Add custom claims to OpenID Connect administration $claims['custom_claim'] = [ 'scope' => 'profile', 'title' => 'Custom Claim', 'type' => 'string', 'description' => 'A custom claim from provider', ]; }
Then you should see "Custom Claim" in the "User claims mapping" form.
PS : the other hook you might need is the hook_openid_connect_userinfo_claim_alter that will help you to rework the values of the custom fields to match the expected values of your Drupal fields.
- πΊπΈUnited States jerrac
I actually did end up implementing hook_openid_connect_claims_alter() and hook_openid_connect_userinfo_alter() to get what I needed. I just left this open because it seems like adding custom scopes should be possible via the UI. Though, judging from the lack of response up until now, it actually isn't, and likely won't be added.
Man, I sure wish I had the money to pay for stuff like this to get added. Or the justification for spending the time implementing it myself.
Anyway, I'm going to leave this open for now. But I won't complain if the maintainers close it as "won't fix" or something.
- πͺπΈSpain antcab
Hello.
I am a newbie developing modules.
What I want is to map an attribute from an external server oauth to a field created in the drupal user account.
That is:
- on my openid server I have the 'center' attribute.
- In the Drupal users account, I have created a center field (field_center).
- In openid connect, I have created a client of type Generic OAuth 2.0.
- In User claims mapping I see the center field created in the user, but I cannot map it to the openid attribute
How do I pass the value of the center to field_center?
I've tried creating the module as lykyd indicates, but no luck.
Drupal version: 10.2.5
Openid Connect Version: 3.0.0-alpha3Thank you very much
- πΊπΈUnited States jerrac
@antcab, That code looks about like what I have.
I don't have the site running right now, so I can't check, but by "User claims mapping" you mean the OpenID Connect module settings form that lets you assign openid values to user profile fields, right? If I remember correctly that is where you actually map the data.
I'm also on the dev version of the module, not the alpha, maybe that'd be something to try.
And, as I'm sure you've heard many many times by now, make sure to clear the cache.