16 votes

Salesforce JWT User Hasn't Approved This Consumer (Again)

From the Salesforce OAuth JWT Flow documentation (hidden): A JWT OAuth 2.0 bearer assertion request looks at all the previous approvals for the user that include a refresh_token. If matching ...
user avatar
  • 481
9 votes

Salesforce JWT User Hasn't Approved This Consumer (Again)

For either the sub or prn value, make sure you are using a username that exists in that org. For the aud make sure you are using test.salesforce.com for a sandbox environment and login.salesforce.com ...
user avatar
  • 343
8 votes
Accepted

Connected App built in SANDBOX has access to PROD

This is a feature of OAuth, and is working as designed. A connected app clientId and secret can be used to connect to any org provided you go through oauth flow and enter username and password (or ...
user avatar
6 votes
Accepted

Rest call with same salesforce org - [Status=Unauthorized, StatusCode=401]

You don't need the Visualforce page. UserInfo.getSessionID() still works, you just cannot System.debug() a session ID - the logs will show SESSION_ID_REMOVED. Your 401 error usually indicates that ...
user avatar
  • 87.3k
6 votes
Accepted

How do I authorize access to a managed application in another org?

I just went through something similar where the final destination varied depending on the customer so a static callback int he code did not work. What I did on our LMA org to handle this was: Placed ...
user avatar
  • 53.2k
5 votes
Accepted

How Can I Access Site.com Studio for a Community Builder Site After Winter '17?

Navigate to Communities | Builder Now observe the URL .Remove of all the extra parameters after domain.The URL would look like below https://googleflowauth-dev-ed--sitestudio.ap1.force.com/ This ...
user avatar
5 votes
Accepted

How to make External Ids ReadOnly in Salesforce?

If integration APIs are creating the record with its unique external ID, the field does not need to be required. Just make it read-only in the layout. If you are concerned that users may create ...
user avatar
  • 3,358
5 votes

Salesforce JWT User Hasn't Approved This Consumer (Again)

"user hasn't approved this consumer" This is a common error caused when the user doesn't have a prior refresh_token associated with him/her. The solution is to perform an Autorization grant (Web ...
user avatar
  • 637
4 votes
Accepted

Need to call salesforce API from external system

Expanding on my comment: The JWT Oauth flow may be what you want, if you're operating a headless back-end application with no user interface. With the JWT flow, you'll create a Connected App in ...
user avatar
  • 87.3k
4 votes

SFDX: Authorize an Org hangs after login attempt

Most of us have this issue with Authorization command. Something may be broken in cli. One workaround is with this command: // authorize production org sfdx auth:device:login // authorize sandbox ...
user avatar
  • 17.8k
3 votes
Accepted

The authorization page for Marketing Cloud

The URI is: https://auth.exacttargetapis.com/v1/requestToken Straight from the docs the whole POST must be as follows :) POST https://auth.exacttargetapis.com/v1/requestToken Content-Type: ...
user avatar
3 votes

Working with Named Credentials spring 15

I am having the same problem with named credentials, and I think I have figured out what's going on. I used Runscope to inspect the headers which are being sent with the HTTP callout. It turns out ...
user avatar
3 votes
Accepted

Error invalid_grant - expired authorization code while running sfdx force:auth:jwt:grant

In the end the problem was in the server time being way off. So if you have this problem, check your CI/CD server time. If it's off, please sync the time using NTP sync: sudo service ntp restart
user avatar
  • 392
2 votes
Accepted

Calling salesforce REST API from sharepoint

I'm not certain if this applies to your situation or not, but I strongly suspect it does. See Knowledge Article Number: 000214836 Integration Options for Salesforce files With the Summer '15 ...
user avatar
  • 40.4k
2 votes

Strip Authorisation header from inbound REST Request

You definitely can't control it from Salesforce's end; Salesforce checks authentication very early in the stack process, before any code you could possibly write could run. Your ideal situation would ...
user avatar
  • 438k
2 votes
Accepted

Google OAuth and Authorization Code

Your understanding is correct. We take the authorization code from the page URL and use it to exchange for the authorization token and refresh token This exchange of the code for tokens is "...
user avatar
  • 22.4k
2 votes

OAuth 2.0 JWT Bearer Token Flow - "user hasn't approved this consumer"

"user hasn't approved this consumer" This is a common error caused when the user doesn't have a prior refresh_token associated with him/her. The solution is to perform an Autorization grant (...
user avatar
  • 637
2 votes
Accepted

Can't get refresh_token in callback with a 'full' scope

Specify both scopes: scope: "refresh_token full", The scope parameter is a space-delimited list of scopes you would like to request. You can specify as many scopes as you need to be as granular as ...
user avatar
  • 438k
2 votes
Accepted

Rest API call to Salesforce from site - one call only

There's going to be at least two calls involved unless you use webhook-style authentication on a Apex REST API endpoint exposed to the public through a Force.com Site. With that style of ...
user avatar
  • 87.3k
2 votes

SFDX: Authorize an Org hangs after login attempt

I had the same error since a few days. Simply doing a "sfdx update" in the command line solved the problem for me... Currently I'm on sfdx-cli version 7.88.4 (sfdx --version)
user avatar
2 votes

Why is the "SFDX: Deploy Source to Org" function missing?

As of today (12.09.2021) my observation is that Deploy option in context menu depends to what kind of org you are connected/authorized to (which one is set as a default one). If it is a sandbox -> ...
user avatar
  • 2,042
2 votes

can we authorize vscode using session id? because i am not able to authorize , it gives error that no event found

A command was recently added to the Salesforce Extension pack to authorize an org using a session ID. Look for 'SFDX: Authorize an Org using Session ID' from the command palette.
user avatar
2 votes
Accepted

Named credential JWT is not appearing in Authorization header in callout

You don't get a "JWT" header, because JWT typically (and in the case of Salesforce) uses the "Authorization" header with the Bearer scheme. The Authorization header contains all ...
user avatar
1 vote

Not getting access token to call Rest API from postman

I it is related to where you put your parameters, they should go in the body, so that your url is This is my request URL https://login.salesforce.com/services/oauth2/token and your body could be ...
user avatar
1 vote
Accepted

How to login from external app without using salesforce login redirection?

You would call login(). To do this, go to Setup > Develop/Integrations > API, download the Enterprise or Partner WSDL, import the WSDL in to your IDE, and call the login method from the client stub. ...
user avatar
  • 438k
1 vote
Accepted

Connected App: Use external ClientId in JWT

tl;dr: No on both questions. Your external user is just going to need to suck it up and make the changes. The documentation you linked doesn't go into detail about exactly what it means by "the ...
user avatar
  • 49.4k
1 vote
Accepted

Why Am I getting invalid_client_credentials with Web Server OAuth Flow?

Found the problem! I had a typo in my token request. It should have been "client_secret" instead of "secret". so it should be: request.AddParameter("application/x-www-form-urlencoded", ...
user avatar
  • 223
1 vote

Salesforce JWT User Hasn't Approved This Consumer (Again)

{"error":"invalid_grant","error_description":"user hasn't approved this consumer"} In my case this error occurred because I was supplying an outdated username. ...
user avatar
1 vote

Named Credentials - Merge Fields not Resolving

I was running into a similar issue. If you are doing a GET call make sure you don't append a body or your request will NOT work with even with the correct headers. If you are doing a POST the ...
user avatar
  • 127
1 vote

Named Credentials - Merge Fields not Resolving

I was having the same issue, but I needed the username and password in the body of the request, I solved this by assigning the merge fields to string variables, then put the variables with all the ...
user avatar

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