11 votes

error=redirect_uri_mismatch&error_description=redirect_uri%20must%20match%20configuration

I had the same problem. I found that callback url in the connected app should be the same as you have in your redirect_uri. I tested it with a tool called postman, maybe that can help you as well.
ChristianJuul's user avatar
9 votes
Accepted

Session Id not getting refreshed automatically with Custom Auth provider in Salesforce Named Credentials

Just an update for anyone facing the same issue. After raising a case with SF we could confirm that the refresh function is only triggered to get new session Id in case the previous callout return '...
Abhijeet Bhandari's user avatar
8 votes

Facebook as Auth Provider - no username or email passed in Auth.Data

Fill the field 'User Info Endpoint URL' (on Auth provider page ) with this and test it out. https://graph.facebook.com/me?fields=first_name,last_name,email Reason for suggestion is: Facebook api v2....
Sergio Valle's user avatar
7 votes
Accepted

Why can't we package custom AuthProvider in Managed Package

Auth Provider is org specific. It has a callback URL where a connected app redirects after authentication and org get authcode and complete the rest authentication steps. If salesforce allows Auth ...
Sushant Srivastava's user avatar
6 votes
Accepted

Custom Auth Provider usage for unattended OAuth flow

You cannot write an initiate method for a Custom Auth Provider without returning a valid PageReference object (i.e. redirect page). Salesforce configuration for Named Credential with a Custom ...
Joe's user avatar
  • 121
6 votes
Accepted

Oauth 2.0 Client Credentials - Custom Auth Provider

I've written a custom authprovider which I've shared "as-is" on Github. It implements both the Client Credentials and JWT Bearer variant (without a certificate). Feel free to fork from it. https://...
Bobby White's user avatar
6 votes

sfdx force:source:pull -> Entity of type 'AuthProvider' named '' cannot be found

Make sure your AuthProvider name has no spaces. I was able to pull the metadata using the retrieve command: sfdx force:source:retrieve -m AuthProvider However, your subsequent pull commands will ...
berardo's user avatar
  • 61
4 votes

Authorize Apex Rest API call using an Azure token

In general, for oauth to work, the user needs to authorise salesforce to perform requests on their behalf. If you haven't done it already, I suggest you go through the documentation on the many ...
Pablo Gonzalez's user avatar
4 votes
Accepted

Connect to Salesforce production REST API from Sandbox using Named Credentials

What is wrong with the above configuration? The Sandbox Org Auth. Provider should have been configured to use: Authorize Endpoint URL: https://login.salesforce.com/services/oauth2/authorize Token ...
Robs's user avatar
  • 9,336
4 votes

Custom REST controller to access Auth.AuthToken.getAccessToken returning null

Edited I did some tests with your code and setup in a Developer Org, Test 1: Log in as the user who created the Auth. Provider in Workbench Result: I can get the token in workbench. Test 2: Grant ...
Adam's user avatar
  • 469
4 votes
Accepted

How to integrate JIRA with salesforce using OAuth 2.0

I was able to authenticate my OAuth 2.0 with the following configuration. For the Auth. provider my Endpoint URL was: https://auth.atlassian.com/authorize?audience=api.atlassian.com My token ...
vdrizzle's user avatar
4 votes

Remote ID limit is 128 characters

I don't think the length of the identifier field can be increased. I'd recommend upvoting this Idea on IdeaExchange platform so that Salesforce Product team can prioritize it. This being a platform ...
Swetha Maddali's user avatar
3 votes
Accepted

How does a Named Credential with a custom Auth. Provider check token validity?

Salesforce closely follows the Oauth2.0 spec for a Named Credential OAuth2.0 flow. When you save and start the Authentication flow, the page reference method initiate is called where your class has ...
Mohith Shrivastava's user avatar
3 votes
Accepted

Can we delete authProvider from APEX

Not all objects allow DML in Apex, even if they are allowed in SOAP, REST, etc. I'm not entirely sure why this restriction exists, but when it does, there's not much you can do. In some contexts, you ...
sfdcfox's user avatar
  • 490k
2 votes

Oauth 2.0 Client Credentials - Custom Auth Provider

Salesforce Premier Support has stated: The Custom Auth provider set up in Salesforce would not allow you to enter client credentials and login. The two posts below also confirm this: Custom ...
S.B.'s user avatar
  • 2,071
2 votes

How is named credentials & auth provider with connected app used? Can i have scenario where it is needed?

From the Named Credentials documentation, an important summary: By separating the endpoint URL and authentication from the callout definition, named credentials make callouts easier to maintain. ...
David Reed's user avatar
  • 92.8k
2 votes

Redirect to Authentication Provider Page instead of salesforce login page

Go to Setup > (Company Settings | Domain Management) > My Domain, edit the Authentication Configuration section, and uncheck all settings except for the provider you want to use. Salesforce will then ...
sfdcfox's user avatar
  • 490k
2 votes
Accepted

sfdx force:source:pull -> Entity of type 'AuthProvider' named '' cannot be found

I was able to selectively pull the problematic metadata using this plugin https://www.npmjs.com/package/@rohanatgwcs/sfdx-selective-retrieve-deploy sfdx gs:source:pull --type AuthProvider --names ...
Robert Sösemann's user avatar
2 votes
Accepted

In need of assistance with writing a Registration Handler Test Class

If you haven't done so already, you should go through the apex testing module on trailhead. It's not going to tell you exactly how to write this test, but it introduces the general concepts (create ...
Derek F's user avatar
  • 61.5k
2 votes
Accepted

How to access OAuth Token stored in NamedCredential using Apex for use in other third party application

Auth.AuthToken.getAccessToken(String authProviderId, String providerName) can get the access token from the auth provider. The call to getAccessToken is made within the currently established security ...
identigral's user avatar
  • 7,556
2 votes
Accepted

Adding extra parameters to Auth Provider URLs

You got to encode those curley brackets and quotes. They're not listed in the characters that should not be encoded. https://en.wikipedia.org/wiki/Percent-encoding https://stackoverflow.com/...
Samuel De Rycke's user avatar
2 votes

Custom auth provider - how to get a new access token without a refresh token

Got this resolved. Hope this helps someone. The application exposing the REST API didn't had offline_access scope configured at their scope. Once this is done, we need add the offline_access scope ...
Jayant Jaiswal's user avatar
2 votes

Package partially configured NamedCredential and AuthProvider

Yes, it is possible to do it, both with the Legacy and NextGen Named Credentials. What would be packaged Named Credential External Credential (in case of a NextGen) An Authentication Provider, as ...
Manuel Moya's user avatar
2 votes
Accepted

How to create Auth Provider using APEX

You can't perform some DML operations in Apex. Instead, use the REST or Metadata API. Here's some code that works in execute anonymous: class AuthProvider { String ProviderType = 'OpenIdConnect'; ...
sfdcfox's user avatar
  • 490k
2 votes

Using Session_Id in Manage Package?

As an ISV you cannot use Session ID for modifying or creating metadata (you can use it for some querying of metadata though). If you do, you will likely fail the security review. I recommend you stick ...
Phil W's user avatar
  • 36.1k
1 vote
Accepted

How to implement PKCE flow in custom external authentication provider?

For anyone finding this thread later and trying todo the same. Me and a college implemented this for Experience Cloud just a few months ago. Initially we tried using a custom object to store and ...
Erlend Hansen's user avatar
1 vote

Setting up MyTrailHead subdomain results in Auth Provider error No_OAuth_Token

My experience is that you cannot do this from a sandbox. I got the same error and when I tried everything from production the problem was solved. I have never seen such a frustrating mix of products ...
Dean Wooldridge's user avatar
1 vote
Accepted

Problem passing error from Auth.RegistrationHandler

Answering my own question, the exception shows up as a ErrorDescription query string on the error page. Custom error page can be defined in Auth Provider setup.
gneek's user avatar
  • 75
1 vote

Salesforce internal server error - SSO through OAuth 2.0 external provider

For me it worked: UserData should contains at least an empty Map of attributes(the last paramter in constructor). Otherwise you will recieve Internal Server error.
Donatello's user avatar
1 vote
Accepted

Can Protected Managed Package Custom Settings be used to store OAuth2.0 Credentials from a Custom Auth Provider?

So it turns out, trying to update Custom Settings doesn't work from inside a custom Auth Provider. At all. It will let you update, insert or whatever while you are inside of the class, but nothing ...
Robert Hyatt's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible