function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Axel Martínez MillánAxel Martínez Millán 

Issue while trying to create Auth Provider

Hello everyone!

I am trying to create a Custom Auth Provider by creating a class that implements Auth.AuthProviderPlugin. I just copied the example shown in the documentation for the API 38, the one I am using, and I tried following the guide at https://help.salesforce.com/articleView?id=sso_provider_plugin_custom.htm&language=en_US&type=0 . 

Unfortunately, when I was creating the Auth Provider in SalesForce, I received the following error:

'Custom Metadata Type is either invalid or null . Check the returned type for getCustomMetadataType() method'
I have tried using different kinds of return values ('CustomSSO__mdt', 'CustomSSO'...) for getCustomMetadataType() and I have checked thoroughly that the Custom Metadata Type exists and the API Name is the one used in getCustomMetadataType().

I have ended up with just this code as the provider plugin, trying to remove as much as I could from the given example, ending up just with the basic skeleton for the plugin:

global class CustomSSOProviderPlugin implements Auth.AuthProviderPlugin {  
    
               global String getCustomMetadataType() {
                   return 'CustomSSO__mdt';
               }
       
               global PageReference initiate(Map<string,string> authProviderConfiguration, String stateToPropagate) {
                   return null;
                }
        
               global Auth.AuthProviderTokenResponse handleCallback(Map<string,string> authProviderConfiguration, Auth.AuthProviderCallbackState state ) {
                   return null;
                }
    
    
                 global Auth.UserData  getUserInfo(Map<string,string> authProviderConfiguration, Auth.AuthProviderTokenResponse response) { 
					return null;             
                 }
                
                global String getTokenValueFromResponse(String response, String token, String ns) {
					return null;
                }  
    
}
I'm pretty sure that I've followed the guide on the SalesForce docs properly, but I can't get past this one error.
 
User-added image

If anyone has any idea of how can this solved, help would be very appreciated!

Thanks in advance!


 

HirokiHiroki
I know it's been a while since this question was posted, but I faced the same issue and somehow made it through.
Here is what I did.

1. I first changed the language of the org to English(I always use Japanese).
2. I changed the returned metadate api name value all in lowercases (this gave me an error saying the api name does not mach).
3. Finally I changed back the returned metadate api name to the exactly same name as the api name.

I hope this may help anyone having the same problem :)
Apex - LearnerApex - Learner
Hi hrk623, I am facing this issue and not able to fix with steps mentioned above. I lowercased my metadata's api name and returned the same from my getMetadatTypeMethod(). Please see the snippet below.
 
global String getCustomMetadataType() { return 'openidtype__mdt'; }
Are you suggesting the same or something else?

Thanks,
Noriko FujisawaNoriko Fujisawa
I faced same issues and solved it.
In my case, I forgot to add CustomMetadata permission for the user who was loiggin to create an Auth Provider configuration in their Profile or PermissionSet.
Please add the permission using Profile or PermissionSet!

Cheers!