Questions tagged [jwt]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
21
votes
1answer
18k views

Authentication using JWT

I am new to use JWT for authenticating external requests. I went through this help article. I am trying to implement above for the following usecase: External application (client) wants to access ...
19
votes
6answers
26k views

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

I know others have asked this question.  The previous solutions have not worked.  Using the OAuth JWT flow.  All Users Can Authorize is selected  User authorized via https://login.salesforce.com/...
11
votes
2answers
6k views

SalesforceDX: Log in to sandbox by username/password from command line without browser involved

Is it possible to log in from sfdx CLI to already existent sandbox having username/password combination? Reading through documentation I see bunch of ways how to authorize - through browser, by ...
11
votes
2answers
2k views

Can I connect to a sandbox using JWT Flow and Prod connect app?

I'm trying to connect to a sandbox using the sfdx cli and the JWT flow through force:auth:jwt:grant. According to this Salesforce DX doc, we can use the same connected app information from Production ...
9
votes
2answers
5k views

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

I am trying to get JWT Bearer Token Flow to work. But get the error user hasn't approved this consumer. I have read these posts: Salesforce JWT User Hasn't Approved This Consumer (Again) OAuth 2....
9
votes
0answers
1k views

How do you use a mock response when calling Auth.JWTBearerTokenExchange.getAccessToken()?

Let's say I have a class like this /** * Example of using JWTBearerTokenExchange to demonstrate issues with testing and mocks */ public class JwtBearerTokenExample { public static String ...
7
votes
0answers
483 views

sfdx force:auth:jwt:grant failure user hasn't approved this consumer - cross machine

This is related to How to open a scratch org created in another machine but posed somewhat differently Given: DevHub with Connected App defined using a digital certificate Correct Oauth scopes ...
6
votes
1answer
3k views

Named Credentials - What is the difference between JWT & JWT Token Exchange

When setting up a named credential with Identity Type as Named Principal, two options are shown for JWT : JWT & JWT Token Exchange Could anyone explain what is the difference between the two? ...
6
votes
1answer
922 views

JWT Bearer Token flow for Community: Invalid Token

I'm implementing a JWT Bearer Token within Salesforce (Apex) so my customers can passwordlessly login to a community. Not sure if it is a good practice, but I done some research and saw some use cases ...
6
votes
1answer
1k views

Server to Server JWT Authentication Certificate management

I'm writing an application to sync some data from a service to salesforce and back. I'm working with a developer account and so far I was able to implement the bulk of the needed functionality merely ...
6
votes
1answer
1k views

Unusual OAuth JWT Bearer Token Flow (Outbound) Integration Pattern

I have a client who's asking me to configure an OAuth JWT Bearer Token integration for them to retrieve delivery status information from a supplier. Salesforce is not the idP. Instead, the flow is ...
6
votes
1answer
1k views

Authorize into developer Sandbox using JWT

I am attempting to authorize a developer Sandbox using JWT in an attempt to implement a CI process. I found this related question on the subject: Can I connect to a sandbox using JWT Flow and Prod ...
5
votes
2answers
7k views

This org appears to have a problem with its OAuth configuration. Reason: invalid_grant - audience is invalid

Error while trying to authorize an org through JWT from SFDX CLI on Windows. sfdx force:auth:jwt:grant --clientid <myclientid> --jwtkeyfile server.key --instanceurl https://mysandbox.my....
5
votes
1answer
2k views

sfdx force:auth:jwt:grant ignoring the instanceurl param

I'm having troubles authenticating to my Dev Hub Org using the JWT token. The command: sfdx force:auth:jwt:grant --clientid *** --username *** --jwtkeyfile *** --setdefaultdevhubusername --...
5
votes
2answers
6k views

JWT Error - user hasn't approved this consumer

I am trying to implement the OAuth 2.0 JWT Bearer Token Flow on my node.js app using these instructions, but I'm unable to authenticate successfully, getting this error: {"error":"invalid_grant","...
5
votes
1answer
292 views

How to verify an Auth0 JWT in a Marketing Cloud Page

We have a requirement to do a verification of a JWT in a SFMC Cloud Page, as we have a site with Client Side JavaScript calling the cloud page and there is no security in SFMC for Cloud Pages. I've ...
4
votes
2answers
2k views

JWT bearer token flow in web app

I am building a web app, which should allow my app users to fetch their Salesforce data for analysis. For this, I am using OAUTH2.0 web server flow. TO avoid refresh_token related complexities, I am ...
4
votes
1answer
2k views

How do I install and preauthorize app so I can use the JWT Bearer token flow?

I'm trying to follow the instructions in https://help.salesforce.com/articleView?id=remoteaccess_oauth_jwt_flow.htm&type=5 and get an invalid request with an error description of "refresh_token ...
4
votes
2answers
437 views

Cannot authorize a Scratch Org via JWT - invalid_grant - user hasn't approved this consumer

I've followed the docs here to create a cert and configured the following; OAuth scopes: api, refresh_token, offline_access and web Permitted users: Admin approved users are pre-authorized Profiles: ...
4
votes
1answer
936 views

Identify Marketing cloud account (user) details - Journey builder custom activity

I am working on custom activity where I need to identify the account (user) details from which the request came to the custom activity REST APIs. I thought setting "useJwt": true in the config.json ...
4
votes
1answer
4k views

Specifying an expiration date/time when creating a JWT

I have a connected app that I would like to connect to using a JWT flow using a bearer token. Using anonymous Apex I have: // The consumer key for a connected app of mine String iss = '<MY ...
4
votes
0answers
119 views

JWT Token Exchange setup in Named Credentials for outbound callout

Trying to integrate with okta api from Salesforce that supports JWT Token exchange. I was able to successfully get the access token with the below code but I am blocked on how to use named credentials ...
3
votes
2answers
1k views

Named Credential with JWT Token Exchange for authorizing calls to Google Cloud

I can make requests with Bearer from Auth.JWT: Auth.JWT jwt = new Auth.JWT(); jwt.setSub('service-portal-rlj@appspot.gserviceaccount.com'); jwt.setAud('https://accounts.google.com/o/oauth2/token'); ...
3
votes
1answer
1k views

Salesforce CI/CD, from Change Set to SFDX with GitLab

I would like to ask about CI/CD in SFDC. Currently my team is doing this: Developing in a sandbox (first sandbox) Testing (UAT) in another sandbox (second sandbox) Deploying our custom codes or ...
3
votes
1answer
2k views

Salesforce OAuth 2.0 JWT Bearer Token Flow - Token Expiration

I am performing Server-Server communication between Salesforce and a Portal I am developing. I implemented the JWT Flow as follows: Created connected app and digitally signed it with certificate ...
3
votes
2answers
1k views

Using the Crypto.verify() method to verify a JWT signature

I am trying to validate a JWT in apex by using the Crypto.verify() method, however, it always returns false despite the fact that I know it is valid. I know it valid because a) I created it and b) I ...
3
votes
1answer
5k views

How to determine the correct 'audience' and 'uri' when using OAuth 2.0 JSON Web Token (JWT) Bearer Token Flow

I have correctly been able to use "OAuth 2.0 Web Server Authentication Flow" and now I'd like to switch to "OAuth 2.0 JWT Bearer Token Flow". I wrote a test application in Node.js with the values two ...
3
votes
1answer
398 views

Oauth throws "invalid_grant: user hasn't approved this consumer" randomly for Community Login profile

I have an OAuth JWT Bearer token flow set up like this: Admin approved users are pre-authorized all profiles added to approved list Relax IP restrictions api, refresh_token/offline_access oauth ...
3
votes
1answer
1k views

OAuth 2.0 JWT Bearer Token Flow refresh_token

According to this SF StackExchange answer, the OAuth 2.0 JWT Bearer Token flow only need a one-time authorisation of the app certificate, and then you can forever issue a OAuth 2.0 JWT Bearer Token ...
3
votes
0answers
57 views

Marketing Cloud Installed Package JWT

We have a package ready to be published on app exchange and wondering if the JWT secret of the package will change for the users installing our package. The JWT is hard coded in our Package.json and ...
3
votes
0answers
544 views

Does SFDX jwt authorization work for scratch orgs as well?

According to the documentation available here https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_auth_jwt_flow.htm it is explicitly mentioned that: You can authorize ...
3
votes
0answers
836 views

How do you use Named Credentials with a Google Cloud API, which requires a JWT to get a token?

Is it possible to used named credentials with a service account to connect to the Google Cloud Platform? I'm trying to make a client to send Pub/Sub messages to Google Cloud from Apex, and it'd be ...
3
votes
1answer
1k views

Log in to Community with OAuth Access Token

I am getting an access token using JWT Bearer Token Flow. I'm trying to log in to a Community through "frontdoor.jsp" with the token. Looking at this question, it doesn't look possible. But the ...
2
votes
1answer
1k views

Error authenticating with JWT config due to: audience is invalid

I've created a connected app based on this Trailhead project. Note that this isn't about a trailhead project I'm using what I've learned from Trailhead in a real-world project to implement CI/CD for ...
2
votes
2answers
154 views

SessionID access vulnerability found when using Metadata API

Salesforce is performing manual security review in our package. They have found SessionID access Vulnerability in one of our file where we are using Metadata API to grant permissions on profile and ...
2
votes
1answer
4k views

Using JWT when calling out from Salesforce to third party API

I have a requirement where on lead conversion in Salesforce, I need to call a third party API and post converted lead's details to that API. I have covered up til the part where we need to add ...
2
votes
1answer
730 views

JWT Token always expires after 'exp' provided in the claims

I've tried implementing a JWT Bearer Token Flow. I followed the documentation on here. The code is originally in Java but I managed to adapt it to c# as the code below shows. String header = "...
2
votes
1answer
759 views

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

I run the command from my build job within Teamcity CI: sfdx force:auth:jwt:grant --clientid '%SFDX_HUB_CONSUMER_KEY%' --jwtkeyfile config/server.key --username %SFDX_HUB_USERNAME% --setalias hub1 --...
2
votes
1answer
2k views

How to know what certificate is associated with a connected app?

I have a connected app and I would like to know what certificate it is associated with. How does one find out that information?
2
votes
1answer
155 views

Named credential JWT is not appearing in Authorization header in callout

I've configured a Named Credential to use the JWT authentication protocol (not JWT Token Exchange), but when the component makes a call to my service using the named credential, I don't get the JWT as ...
2
votes
2answers
184 views

SF required multi-factor authentications starting February 2022 OAuth JWT Bearer Token flow

I am using JWT flow described bellow https://help.salesforce.com/articleView?id=sf.remoteaccess_oauth_jwt_flow.htm&type=5 and SF required multi-factor authentications starting February 2022 ...
2
votes
1answer
657 views

Allow external users to access customer community SSO/JWT

Use Case: Coming from the client website, the external users need to be log into their customer communities account without having to log again. I know that I could use SAML for this use case, but ...
2
votes
1answer
2k views

Decode JWT Token in Apex [closed]

I am trying decode JWT token in apex, and i am not sure how that can be done. If anyone has done that before, please let me know the process. A JWT token is sent to SFDC and need to decode it in apex ...
2
votes
1answer
2k views

How generate a JWT token for Metabase using Apex [closed]

I have to embed a Metabase Iframe into Salesforce via an lwc. The metabase itself gives me the code below in Node.js as an example. var jwt = require("jsonwebtoken"); var METABASE_SITE_URL = "...
2
votes
1answer
493 views

ERROR running force:auth:jwt:grant: Destination URL not reset. The URL returned from login must be set

I'm trying to setup CI/CD with Jenkins for the first time. I already have a valid script running in Bitbucket Pipelines, but now we need to move to the client provided Jenkins server. This is my ...
2
votes
1answer
2k views

Create self-signed x509 certificate

I am trying to get an access token by following the guide OAuth 2.0 JWT Bearer Token Flow. But I am stuck on the following The developer writes an app that generates a JWT. The JWT is signed with ...
2
votes
1answer
2k views

Show user profile image - third party site

I am using Salesforce REST API to pull in the user profile salesforce object into my external site. I wanted to be able to display things like about me, title, and image on my site. I get all of this ...
2
votes
1answer
700 views

JWT oauth flow "session expired" error

I'm working with a website developer to do some integration with a Salesforce REST API that I've written. We're using JWT oauth flow for the website to authenticate with the Salesforce sandbox. The ...
2
votes
1answer
512 views

Using the OAuth JWT flow with guest users in a Lightning Community

We're using the JWT flow to retrieve session IDs for the current user in a Lightning Community, for use in code running outside of Salesforce. In particular, we use that session ID to run SOSL queries ...
2
votes
1answer
38 views

error in node JS and SF integration via jsforce using JWT

Premise: I need to integrate SF with NodeJs using JWT. I'm following Salesforce Developers Session for this purpose. As of now the entire setup of NodeJs is only in local. According to the video I ...