Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
edited body
Source Link
Sarvesh
  • 998
  • 13
  • 32

I created one connected app in Salesforce. I am doing every time two callout one for outh2.0 and another for actual apexrest callout. I want to avoid outh2.0 callout every time. The following solution in my mind but facing some issue. 1- Use refresh token to get a new access token 2- Use expire time limit of the access token to make a new callout for authentication.

The problem I facing.

  • When the first time I make a callout for authentication like Outh2.0 I am getting a successful response but I need refresh token. so with the help of refresh token, I can make a call out for new authenticate access token when the previous access token is invalid.

  • I am also not getting time limit of the access token, generally other ooth2outh2.0 we are getting the expire_in key in response but through the connected app, I am not getting such type of key

Let me know if there is another way to authenticate and not call every time for authentication to avoid redendency.

here is my code for outh

String reqbody = 'grant_type=password&client_id='+clientId+'&client_secret='+clientSecret+'&username='+username+'&password='+password;
    Http h= new Http();
    HttpRequest req= new HttpRequest();
    req.setBody(reqbody);
    req.setMethod('POST');
    req.setEndpoint('https://test.salesforce.com/services/oauth2/token');
    HttpResponse res=h.send(req);

I created one connected app in Salesforce. I am doing every time two callout one for outh2.0 and another for actual apexrest callout. I want to avoid outh2.0 callout every time. The following solution in my mind but facing some issue. 1- Use refresh token to get a new access token 2- Use expire time limit of the access token to make a new callout for authentication.

The problem I facing.

  • When the first time I make a callout for authentication like Outh2.0 I am getting a successful response but I need refresh token. so with the help of refresh token, I can make a call out for new authenticate access token when the previous access token is invalid.

  • I am also not getting time limit of the access token, generally other ooth2.0 we are getting the expire_in key in response but through the connected app, I am not getting such type of key

Let me know if there is another way to authenticate and not call every time for authentication to avoid redendency.

here is my code for outh

String reqbody = 'grant_type=password&client_id='+clientId+'&client_secret='+clientSecret+'&username='+username+'&password='+password;
    Http h= new Http();
    HttpRequest req= new HttpRequest();
    req.setBody(reqbody);
    req.setMethod('POST');
    req.setEndpoint('https://test.salesforce.com/services/oauth2/token');
    HttpResponse res=h.send(req);

I created one connected app in Salesforce. I am doing every time two callout one for outh2.0 and another for actual apexrest callout. I want to avoid outh2.0 callout every time. The following solution in my mind but facing some issue. 1- Use refresh token to get a new access token 2- Use expire time limit of the access token to make a new callout for authentication.

The problem I facing.

  • When the first time I make a callout for authentication like Outh2.0 I am getting a successful response but I need refresh token. so with the help of refresh token, I can make a call out for new authenticate access token when the previous access token is invalid.

  • I am also not getting time limit of the access token, generally other outh2.0 we are getting the expire_in key in response but through the connected app, I am not getting such type of key

Let me know if there is another way to authenticate and not call every time for authentication to avoid redendency.

here is my code for outh

String reqbody = 'grant_type=password&client_id='+clientId+'&client_secret='+clientSecret+'&username='+username+'&password='+password;
    Http h= new Http();
    HttpRequest req= new HttpRequest();
    req.setBody(reqbody);
    req.setMethod('POST');
    req.setEndpoint('https://test.salesforce.com/services/oauth2/token');
    HttpResponse res=h.send(req);
Source Link
Sarvesh
  • 998
  • 13
  • 32

I am not getting refresh token on outh2.0 using Connected App in salesforce

I created one connected app in Salesforce. I am doing every time two callout one for outh2.0 and another for actual apexrest callout. I want to avoid outh2.0 callout every time. The following solution in my mind but facing some issue. 1- Use refresh token to get a new access token 2- Use expire time limit of the access token to make a new callout for authentication.

The problem I facing.

  • When the first time I make a callout for authentication like Outh2.0 I am getting a successful response but I need refresh token. so with the help of refresh token, I can make a call out for new authenticate access token when the previous access token is invalid.

  • I am also not getting time limit of the access token, generally other ooth2.0 we are getting the expire_in key in response but through the connected app, I am not getting such type of key

Let me know if there is another way to authenticate and not call every time for authentication to avoid redendency.

here is my code for outh

String reqbody = 'grant_type=password&client_id='+clientId+'&client_secret='+clientSecret+'&username='+username+'&password='+password;
    Http h= new Http();
    HttpRequest req= new HttpRequest();
    req.setBody(reqbody);
    req.setMethod('POST');
    req.setEndpoint('https://test.salesforce.com/services/oauth2/token');
    HttpResponse res=h.send(req);