• camelUser
  • NEWBIE
  • 25 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 2
    Replies

I have a situation where i need to get the infomation of a connected app via apex, spacificly i need access to the Client Id and Client Secret can anyone tell me if this is possable / provide a basic example?

 

I thought i would be able to get this via SOQL but in not having much luck.

 

 

I am trying to create a process using the salesforce process builder that triggers an apex class method when a  user changes there password.

The process type is: A record changes

The recored is: User

Record type

The condition is: User.LastPasswordChangeDate is Changed (True)

condition


The Immediate Action is: pass [USER] to the apex class invocable method
 

action

My apex method is:

@InvocableMethod(label='Trigger user refresh call' description='Trigger the user refresh when the password is manualy changed')
    public Static void triggerUserRefresh(List<User> user){
        if(user.isEmpty()){
            System.debug(InvocableMethod triggerUserRefresh user list was empty, this integration was not triggered.'); 
        }else{
        	System.debug('Integration user refresh has been manualy triggerd.'); 
            User singleUser = user.get(0);
            
            String username = singleUser.Username;
            setVariables();
            String message = 'The Salesforce integration user has been has been manualy triggerd, create new ticket';
            notifyOfUserReset(message); 
        }
    }

The issue: This process never seems to run when a user changes there password, I see no record of anything running from the developer console log.

I know the method works as I am able to test that independently from the process and i get the result I expect.

Am I doing something incorrect?

Is there a was to enable more logging to see if the process is being triggered / the failure?

Any help would be greatly appreciated.

How do i access the infomation on the Advanced User Detailspage via SOQL? i cant see any object that contains the data i am looking for, the user object does not seem to contain the 'Last Password Change or Reset' field.

The user object does conatin the field PasswordResetLockoutDate however when attempting to grab this value i get the error:

 

"No such column 'LastPasswordChangeOrReset' on entity 'User'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names."

I'm looking to create a process that will trigger an apex class when the user password is X number days away from expiring (only trigger once not over and over)  is this possible? I know SF has an email flow but that's not what I'm looking for.

Is it possible to use the process builder for this?

Is it possable to create an internal process that triggers when a user requests a new security token?
/ have that token forwarded on to a apex class ?

I cant see the token referanced against the user object in the salesforce Process Builder.

 

Using the Salesforce process builder i can see that i can create a new process to that calles an apex class when the users password is changed, what i want to know is it possable to get a users password to use in the class if i allready know the id?

I Have created an integration that updates Opportunity Data and creates new ContentVersion (Documents), i have created a connected app (web server flow) to allow the integration to authenticate via OAUTH and make the required changes.

Problem: The issue is that a single user is used for the whole integration meaning if the users password happens to expire (we are unable to set this to not expire based because of company procedure) or if the user happens to request a new security token (Profile > My personal infomation > Reset My Security Token) then the call to generate a access token will fail and the integration is effectivly offline untill the the settings can be alterd.

I have been told that using a refresh token could help in preventing this issue, is this correct / does any one have some basic curl examples i can refer to?

What i am trying to achieve: Allow the integration to continue if the users Access Token has been changed / if the users password has expired.

Current process: Currently on each call to Salesforce i first preform a call to get an OAuth token, which is then used in the next call e.g. update opportunity.

Call represented by the curl statment below.

curl https://example.my.salesforce.com/services/oauth2/token -d "grant_type=password" -d "client_id=EXAMPLE_4446575" -d "client_secret=EXAMPLE_4545441" -d "username=example@example.com" -d "password=Password+Security Token"
on sucessful call i get 
{
    "access_token": "accesstoken_636366363",
    "instance_url": "https://example.my.salesforce.com",
    "id": "https://test.salesforce.com/id/054445554454",
    "token_type": "Bearer",
    "issued_at": "example_1556289115669",
    "signature": "example_4844848488484484844848484844884
}
When Token or Password has expired or changed i get:
 
{
    "error": "invalid_grant",
    "error_description": "authentication failure"
}

I thought that in this case useing a refresh token call would get me a new Access Token, this is what i tried:
 

curl https://example.my.salesforce.com/services/oauth2/token -d "grant_type=refresh_token" -d "client_id=EXAMPLE_4446575" -d "client_secret=EXAMPLE_4545441" -d  "refresh_token=accesstoken_636366363"

I get the ERROR:

{
	"error":"invalid_grant",
	"error_description":"expired access/refresh token"
}


On investergation i can see that this error is commen if i havent selected the "Perform requests on your behalf at any time (refresh_token, offline_access)" scoope in my connected app, however this is sellected.

Does Anyone have any ideas what i am doing incorrectly / if this is not the correct method for what i am trying to achieve / what other applications do to overcome the integration user expiring issue?

When trying to refresh my user token via the API i receve the below error, i am trying to test out an integration  work arround for when the integration password is reset / security token expires.

{
    "error": "invalid_grant",
    "error_description": "expired access/refresh token"
}


I have tried to make the request via Curl and using Postman but receve the same error, as far as i can tell i have all of the appropiate rights set up on my connected app.

connected app
Example Curl request:

curl POST https://eu16.salesforce.com/services/oauth2/token -d "grant_type=refresh_token&client_id=3MVG9f..............................svQ10&client_secret=97E8475611A9...............................096391&refresh_token=lZI..........ZSQ"

I have redacted the sensitive infomation above, but this is the data i am entering:

client_id = This is the Consumer Key taken from the connected app screen

client_secret = This is the Consumer Secret  taken from the connected app screen

refresh_token = This is the user security token (Obtained from settings -> My Personal Infomation -> Reset Security Token) 

Is anyone able to detail what i am doing incorrectly?

When uploading a document either by the API or form the ui i notice that it is only accessable by the user who uploaded it, i can see that form the UI atleast i can share with indevidual user so that they can also access it.

is there a method to share the document with all users?

is there a method to share the document from the API?
- make it avalibe via a file 'Related list' on an opportunity?

I have taken a look through the forum and cant find what i am after so i might have the wrong method here.

I need to upload files to Salesforce via an API and need use Salesforce Files (not attachments) so we can version files if needed. I also need to make sure that the resulting uploaded file is available to all users.
The upload of the file seems to be straight forward enough from what i have read i should be using the chatter API to upload the document to Files home (https://developer.salesforce.com/docs/atlas.en-us.chatterapi.meta/chatterapi/intro_input.htm) "Upload a file to the Files home" section.

The trouble is the "files home" endpoint url is user specific.

What i need to achieve via the API:

1. Upload a file to files home.
2. Share the uploaded file with an Opportunity so that is is visible on the opportunity via the files related list.
Potentially share the file with other users / all users

Points 2 and 3 i am struggling with does anyone have an example / thread they can point me to.

i am unable to login as a user using REST API, same is working fine with Administrator. Can any one please help me out in this ?

I have assigned all required permissions for user ( API Enabled, Modify all data, Connected apps and also crated connected app).

Tried with user by assigning system administrator profile, still its not working.

When trying to refresh my user token via the API i receve the below error, i am trying to test out an integration  work arround for when the integration password is reset / security token expires.

{
    "error": "invalid_grant",
    "error_description": "expired access/refresh token"
}


I have tried to make the request via Curl and using Postman but receve the same error, as far as i can tell i have all of the appropiate rights set up on my connected app.

connected app
Example Curl request:

curl POST https://eu16.salesforce.com/services/oauth2/token -d "grant_type=refresh_token&client_id=3MVG9f..............................svQ10&client_secret=97E8475611A9...............................096391&refresh_token=lZI..........ZSQ"

I have redacted the sensitive infomation above, but this is the data i am entering:

client_id = This is the Consumer Key taken from the connected app screen

client_secret = This is the Consumer Secret  taken from the connected app screen

refresh_token = This is the user security token (Obtained from settings -> My Personal Infomation -> Reset Security Token) 

Is anyone able to detail what i am doing incorrectly?