Welcome to catchontosalesforce!
Description :
We used to renew access tokens issued by OAuth 2.0 web server flow or the OAuth 2.0 user-agent flow.
For refresh access token, It's used to reduce subsequent credential login in Authorization Code and Credentials Flow for Public/ Private Clients. we just use refresh token to renew access token whenever access token is expired.
API Details :
Example,
In Client custom app, we ask key-in username and password to authorize user and get access token to access salesforce protected data. If you skip subsequence user login/authorization, the OAuth 2.0 Refresh token policy will help you.
Apex :
HttpRequest req = new HttpRequest();
req.setEndpoint(<Your Experience Site URL>+'/services/oauth2/token');
req.setMethod('POST');
Blob headerValue = Blob.valueOf(<ClientId> + ':' + <ClientSecret>);
req.setHeader('Authorization', 'BASIC ' +EncodingUtil.base64Encode(headerValue));
req.setHeader('grant_type', 'refresh_token');
req.setHeader('refresh_token', <Refresh_Token>);
Http http = new Http();
HttpResponse res = http.send(req);
System.debug(res.getbody());
Thanks
Priyananth
Comments
Post a Comment