Questions tagged [jwt]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
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? ...
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 ...
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/...
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 ...
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....
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 ...
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 ...
0
votes
1answer
2k views

Export a private key associated with a self-signed certificate

As part of our CI/CD with Azure, we were able to successfully authorize an Org using the JWT-Based Flow AS LONG AS we follow the steps here Every time we refresh our sandboxes, we have to go through ...
4
votes
1answer
930 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
2answers
436 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: ...
3
votes
1answer
396 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
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
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 ...
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
3k views

Salesforce connecting to a JWT service via Named Credentials - JWT Token Exchange

Use Case I would like to prepare a demo for a client where we can from Salesforce access a third-party API. The authentication protocol for the external third-party API is SF will issue a JWT and ...
1
vote
1answer
193 views

Generate JWT token for external app - SSO

We are setting up a Salesforce Community and our community members should be able to automatically login using the credentials from an extenal platform when clicking on a link from this platform. I'm ...
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....
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 ...
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 ...
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 ...
2
votes
2answers
1k views

Generate a JWT with HS256 signature

I am trying to generate an HS256 signed JWT token via Apex. I am using this token in the Authy registration process to enable 2FA for community users. Per the Authy documentation HS256 is the only ...
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 ...
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 ...
1
vote
2answers
1k views

JWT, Cyrpto.Sign and EncodingUtil.base64Encode

I'm writing my own class to create a JWT. Using the JSONGenerator I am creating the header and payload, base64 encoding these with EncodingUtils. I am then creating a blob from these to sign and use ...
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
491 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

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 ...
1
vote
1answer
753 views

JWT Bearer flow vs. Username+Password flow in server-to-server integration

Official documentation and some SFSE answers advise against the use of Username + Password flow (Resource Owner Password Credentials Grant in oauth). The JWT Bearer flow is also recommended as a ...
1
vote
2answers
855 views

Ruby - OAuth 2.0 JWT Bearer Token Flow

I am following this document as I try to implement the Salesforce OAuth 2.0 JWT Bearer Token Flow. There are a number of steps involved and I have tried them over and over again but I keep getting {"...
0
votes
1answer
91 views

JWT connectiong failing with Connected App in a Different Org

We have two SF orgs SF1 and SF2. In SF1, we create a connected app, uploaded a digital certificate, and have policy of 'Admin Authorized user'. We added the needed profile. The client is able to ...
0
votes
1answer
193 views

{"error":"invalid_grant","error_description":"invalid assertion"} I want to send post request to Salesforce [closed]

I am trying to send post request to salesforce for Oauth by using JWT and I wrote it like the one below, but I got an error that says {"error":"invalid_grant","...
0
votes
3answers
2k views

Add custom claims to OpenID Connect id token - Web Server Authentication flow

We are using Keycloak to generate OpenID Connect id tokens, now they want to use Salesforce Identity to do that. We have some custom claims in the id token returned by Keycloak that we are not able to ...
0
votes
0answers
46 views

Adding custom claims to access token in oAuth JWT Bearer flow [duplicate]

My requirement is to retrieve additional attributes via JWT Flow. For that I developed a connected app plugin class and added it to the connected app. Although i am able to get the access token, it ...