I am using LWC for integration my application. I need to get the Personal Access Token at runtime. Is that possible to get?  Presently, I hardcode Personal Access Token in my LWC application. like this:   Http.setRequestHeader("Authorization", 'Bearer XXXXXXXXXXXXXXX');  i have clientId, ClientSecret, username and password. can i do auth 2.0 with it?  I am not able to get the Personal Access Token.
31428
I have a requirement to make a call to the  from a Lightning component. The issue I am facing is that there is currently no native support for acquiring a valid API session ID from an @AuraEnabled method in a Lightning component Apex controller.  The Lightning developer  states that a named credential can be used in order to bypass this security restriction. However, when I set up a named credential and then pass that named credential reference as the endpoint for the Metadata Service API, I am receiving the following error:     "FATAL_ERROR System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: INVALID_SESSION_ID: This session is   not valid for use with the API faultcode=sf:INVALID_SESSION_ID   faultactor=".   I have found a potential  using Visualforce. However, the thread presenting this work around does not reference the "Named Credentials" feature as an option.  This  also presents the same issue where the documented named credential stops have been followed and the same error is received, but no solution has yet been offered.   I am not able to understand why the named credential feature is not bypassing the session id security measure for Lightning components.  Any input would be greatly appreciated.
108761
We are using SharePoint Online. I am planning to add a flow to send out an email notification whenever a new page is added to the site.   To do that, I need the list of members of that site cause I don't want to send it to everyone or anyone.   I am unable to retrieve the group members through REST API. When I fire the following REST call, I am getting the response as follows, but not the actual members and their email addresses  https://dhdigitalcoin.sharepoint.com/sites/OpenSourceTechTalk/_api/web/sitegroups/getbyname('Open%20Source%20Tech%20Talk%20Members')/users   &lt;entry&gt; &lt;id&gt;https://dhdigitalcoin.sharepoint.com/sites/OpenSourceTechTalk/_api/Web/GetUserById(7)&lt;/id&gt; &lt;category term="SP.User" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/&gt; &lt;link rel="edit" href="Web/GetUserById(7)"/&gt; &lt;link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Alerts" type="application/atom+xml;type=feed" title="Alerts" href="Web/GetUserById(7)/Alerts"/&gt; &lt;link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Groups" type="application/atom+xml;type=feed" title="Groups" href="Web/GetUserById(7)/Groups"/&gt; &lt;title/&gt; &lt;updated&gt;2019-06-03T12:47:56Z&lt;/updated&gt; &lt;author&gt; &lt;name/&gt; &lt;/author&gt; &lt;content type="application/xml"&gt; &lt;m:properties&gt; &lt;d:Id m:type="Edm.Int32"&gt;7&lt;/d:Id&gt; &lt;d:IsHiddenInUI m:type="Edm.Boolean"&gt;false&lt;/d:IsHiddenInUI&gt; &lt;d:LoginName&gt;c:0o.c|federateddirectoryclaimprovider|92b9f118-885e-4c23-a103-de7ce46d7421&lt;/d:LoginName&gt; &lt;d:Title&gt;Open Source Tech Talk Members&lt;/d:Title&gt; &lt;d:PrincipalType m:type="Edm.Int32"&gt;4&lt;/d:PrincipalType&gt; &lt;d:Email&gt;OpenSourceTechTalk@xxx.onmicrosoft.com&lt;/d:Email&gt; &lt;d:Expiration/&gt; &lt;d:IsEmailAuthenticationGuestUser m:type="Edm.Boolean"&gt;false&lt;/d:IsEmailAuthenticationGuestUser&gt; &lt;d:IsShareByEmailGuestUser m:type="Edm.Boolean"&gt;false&lt;/d:IsShareByEmailGuestUser&gt; &lt;d:IsSiteAdmin m:type="Edm.Boolean"&gt;false&lt;/d:IsSiteAdmin&gt; &lt;d:UserId m:null="true"/&gt; &lt;d:UserPrincipalName m:null="true"/&gt; &lt;/m:properties&gt; &lt;/content&gt; &lt;/entry&gt;   Is there a way I can retrieve the actual members?  Am I taking the right approach towards building email notifications?
11711
I've got the directive  &lt;VirtualHost *&gt;     &lt;Location /&gt;         AuthType Digest         AuthName "global"         AuthDigestDomain /         AuthUserFile /root/apache_users         &lt;Limit GET&gt;             Require valid-user         &lt;/Limit&gt;     &lt;/Location&gt;     WSGIScriptAlias / /some/script.wsgi     WSGIDaemonProcess mywsgi user=someuser group=somegroup processes=2 threads=25     WSGIProcessGroup mywsgi     ServerName some.example.org &lt;/VirtualHost&gt;   I'd like to know in the /some/script.wsgi  def application(environ, start_response):     start_response('200 OK', [         ('Content-Type', 'text/plain'),     ])     return ['Hello']   What user is logged in.  How do I do that?
56430
I'm not able to get refreshApex() working in an lwc. . Here are the key elements of the js file:  import { LightningElement, track, api, wire } from 'lwc'; import getBlasts from '@salesforce/apex/Blast.getBlasts'; import { refreshApex } from '@salesforce/apex';  export default class BlastWaveTree extends LightningElement {     @api recordId;     @track blastData;     @track error;     @wire(getBlasts, { CampaignId: '$recordId' })         wireBlastData({             error,             data         }) {             if (data) {                 let tempjson = JSON.parse(JSON.stringify(data).split('waves').join('_children'));                 this.blastData = tempjson;          } else {                 this.error = error;         }     }      @api     refresh() {         return refreshApex(this.blastData);      }   My code varies from the doc examples for 2 reasons:    The example code doesn't separate out the Apex response into error and data, the pattern I've been following as shown elsewhere. This data is going into a lightning-tree-grid so I have to process it a bit before assigning it to blastData.   I've tried return refreshApex(this.wireBlastData) as well, and that doesn't work.  Ultimately, I want to call the refresh function from the parent component (hence, the @api), but I've simplified it (till I get it working) by calling the refresh function from a button on this same component. I added a console.log line in the refresh() function so I know the button is calling the function. It just doesn't refresh. I'm also watching the apex logs as I push the refresh button, and there's no apex activity.  Here's the template:  &lt;template&gt; &lt;lightning-card title="Blasts" icon-name="custom:custom3"&gt;     &lt;div slot="actions"&gt;         &lt;lightning-button-group &gt;             &lt;lightning-button-icon icon-name="utility:refresh"  alternative-text="Refresh" onclick={refresh}&gt;&lt;/lightning-button-icon&gt;             &lt;lightning-button label={buttonLabel} onclick={toggleWaves}&gt;&lt;/lightning-button&gt;              &lt;lightning-button label="New Blast" onclick={onNewBlast} variant="Brand"&gt; &lt;/lightning-button&gt;         &lt;/lightning-button-group&gt;     &lt;/div&gt;     &lt;div class="slds-m-around_medium"&gt;         &lt;lightning-tree-grid              data={blastData}              columns={columns}              key-field="id"              hide-checkbox-column="true"              onrowaction={handleRowAction} &gt;         &lt;/lightning-tree-grid&gt;     &lt;/div&gt; &lt;/lightning-card&gt;     What am I missing?  Here's the error detail from the browser dev tools:      lds.js:2 Uncaught (in promise) Error: Refresh failed because resolved configuration is not available.     at Object.e.refresh [as refreshApex] (lds.js:2)     at l.refresh (blastWaveTree.js:4)     at callHook (aura_prod.js:24)     at sa (aura_prod.js:2)     at aura_prod.js:2     at _ (aura_prod.js:2)     at HTMLElement.e (aura_prod.js:2)     at l (aura_prod.js:2)     at Un.call.a (aura_prod.js:2)     at Array.forEach (&lt;anonymous&gt;) e.refresh   @   lds.js:2 refresh @   blastWaveTree.js:4 callHook    @   aura_prod.js:24 sa  @   aura_prod.js:2 (anonymous) @   aura_prod.js:2 _   @   aura_prod.js:2 e   @   aura_prod.js:2 l   @   aura_prod.js:2 Un.call.a   @   aura_prod.js:2 t   @   aura_prod.js:2 Lt  @   aura_prod.js:2 t.$$lwcEventWrapper$$   @   aura_prod.js:2
61310
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   Every time we refresh our sandboxes, we have to go through the whole process again, which is a bit of a pain.  Question is, do you guys know if I can generate a server.key file (which is requried by the JWT Flow) from a self-signed certificate created within Salesforce, and not openssl?  Thanks.
21658
Background:  I have created a custom Auth. Provider in Salesforce to reach out to an authorization server that isn't on the default list of Provider Types. I used  as a good starting point to extend the Auth.AuthProviderPluginClass. Once appropriately added to my org, it then became an option on the list of Provider Types. I was able to create an Auth. Provider using that new provider type and it works to initiate the OAuth2.0 flow. I am appropriately able to get the access token and refresh token from the authorization server.  The Problem:  As it currently stands, we will have users click on a button that will send them to the provided "OAuth-Only Initialization URL" link that was generated when I created the actual Auth. Provider record. The trick is that when the OAuth2.0 flow is completed, the user is redirected back to the Salesforce Setup Home page, and I don't see a good way in the documentation to override the final destination to be something else (like a success page or something).  Question:  Does anyone know of a way to override the final destination of the OAuth2.0 flow from a custom OAuth2.0 Auth provider?    UPDATE: I tried using the startUrl (and also tried retUrl for good measure) as query params, but doing so didn't change the behavior after the OAuth2.0 flow finished.  Meaning, both of the following URLs gave me the same final destination as not having any query params at all:  https://&lt;scratch org random url&gt;.my.salesforce.com/services/auth/oauth/MyCustomAuthProvider?retUrl=lightning%2Fpage%2Fhome   https://&lt;scratch org random url&gt;.my.salesforce.com/services/auth/oauth/MyCustomAuthProvider?startUrl=lightning%2Fpage%2Fhome     Another Update: This WORKED:  https:/&lt;scratch org random url&gt;.my.salesforce.com/services/auth/oauth/MyCustomAuthProvider?startURL=%2Flightning%2Fn%2FCustomPage   Apparently, it was important to add the leading /, (of course, url encoded to be %2F) and %2Flightning%2Fpage%2Fhome gets interpreted as the setup home and sends you there.    (Parallel posted to Salesforce Dev Forum: )
55093
API only users cannot login and choose 'Reset my security token'. Right now, in my company, we select a System Administrator profile for users, log in for the first time, choose 'Reset my security token', then change the profile to a custom profile which has API only enabled.  The other way of doing it is, modifying the profile to not have API only user checked initially and then turn it on once the security token is received.  Is there a recommend way to do this? Is there an option to force the security token to be sent  when the user is created with a profile which has API user enabled?
109231
I am able to make an apex callout by passing the username and password in the request body.  String endpoint='https://xyz...com/'; String userID='xyz'; String password='pass'; String jsonBody ='userID=' + userID + '&amp;password=' + password; HTTP auth = new HTTP(); HTTPRequest r = new HTTPRequest(); r.setClientCertificateName('certificate_Name'); r.setEndpoint(endpoint); r.setMethod('POST');    r.setBody(jsonBody); r.setHeader('Content-Type','application/x-www-form-urlencoded'); HTTPResponse authresp=new HttpResponse(); authresp = auth.send(r);  system.debug(authresp);   I have a requirement to use the above same approach of passing the credential in request body but I have to do it using Named Credentials.  I did go through the link -  to learn that -      The Salesforce admin must set up the named credential to allow Apex   code to construct headers or use merge fields in HTTP headers or   bodies.   I am trying some approach to include the named credentials in the above code but I am do not get a success result so far. Below is what I tried:  Named Credential:    Code using Named Credential:      HTTP auth = new HTTP();     HTTPRequest r = new HTTPRequest();     r.setEndpoint('callout:Named_CREDENTIAL');     String jsonBody ='userID=' + '{!$Credential.Username}' + '&amp;password=' + '{!$Credential.Password}'; r.setBody(jsonBody);     r.setMethod('POST');        r.setHeader('Content-Type','application/x-www-form-urlencoded');     HTTPResponse authresp=new HttpResponse();     authresp = auth.send(r);      system.debug(authresp);   Response I got - System.HttpResponse[Status=Forbidden, StatusCode=403]
26360
The Drupal 8 REST UI configuration page asks me to select Authentication providers for GET method; otherwise, it doesn't allow me to export the REST request.  How can I provide anonymous user to access my REST GET API without providing any auth information?
19646
I have a Spring MVC web app which uses Spring Security.  I want to know the username of the currently logged in user.  I'm using the code snippet given below .  Is this the accepted way?    I don't like having a call to a static method inside this controller - that defeats the whole purpose of Spring, IMHO.  Is there a way to configure the app to have the current SecurityContext, or current Authentication, injected instead?      @RequestMapping(method = RequestMethod.GET)   public ModelAndView showResults(final HttpServletRequest request...) {     final String currentUser = SecurityContextHolder.getContext().getAuthentication().getName();     ...   }
109554
I'm looking at the shadow Dom in the lwc developer guide and found below  statements.   Shadow DOM is a web standard. To make development easier for component authors, the Lightning Web Components shadow DOM works a bit differently than the web standard.One difference is that the shadow DOM for a Lightning web component is created automatically. The component author doesn’t have to implement it (no need to use the attachShadow() or appendChild() methods). Also, a Lightning web component’s shadow DOM works even on platforms that don’t natively support shadow DOM, such as some web browsers. Since Lightning web components don’t use the native shadow DOM yet, you can’t view their shadow DOM in Chrome Developer Tools. Even if you enable Show user agent shadow DOM, you don’t see the shadow DOM.      My Question: Is shadow dom in lwc used just to encapsulate framework   methods? Also is there anything a developer need to keep in mind   while working with lwc in terms of shadow Dom?
112703
My goal is to get the login name and picture for the current user. I am using SharePoint 2013 Foundation. I tried three method and non of then worked correctly:   This is with jQuery SPServices:   function getCurrentUserInfo() {     var thisUsersValues = $().SPServices.SPGetCurrentUser({         fieldNames: ["ID", "Name", "Picture"],         debug: false     });      var name = thisUsersValues["Name"];      var ID = thisUsersValues["ID"];      var SIPAddress = thisUsersValues["Picture"];  }    But I am getting this error:     SCRIPT438: Object doesn't support property or method 'replace'      File: jquery.SPServices-2014.01.js, Line: 2414, Column: 17    REST API method:   function getinfo(loginName) {     var theData = {         "propertiesForUser": {             "__metadata": { "type": "SP.UserProfiles.UserProfilePropertiesForUser" },             "accountName": loginName,             "propertyNames": ["PreferredName", "PictureURL"]         }     };      var requestHeaders = {         "Accept": "application/json;odata=verbose",         "X-RequestDigest": jQuery("#__REQUESTDIGEST").val()     };      jQuery.ajax({         url: _spPageContextInfo.webAbsoluteUrl + "/_api/SP.UserProfiles.PeopleManager/GetUserProfilePropertiesFor",         type: "POST",         data: JSON.stringify(theData),         contentType: "application/json;odata=verbose",         headers: requestHeaders,         success: function (data) {             document.getElementById("profilelink").href = userProfileProperties[1];;             document.getElementById("username").innerHTML = userProfileProperties[0];             if (userProfileProperties[1] !== null) {                 document.getElementById("Userprofileimage").src = userProfileProperties[1];             }         },         error: function (jqxr, errorCode, errorThrown) {             console.log(jqxr.responseText);         }     }); }    Error:     "{\"error\":{\"code\":\"-1,        Microsoft.SharePoint.Client.InvalidClientQueryException\",\"message\":{\"lang\":\"en-US\",\"value\":\"The method         GetUserProfilePropertiesFor cannot be invoked as its parameter propertiesForUser is not supported.\"},\"innererror\":        {\"message\":\"The method GetUserProfilePropertiesFor cannot be invoked as its parameter propertiesForUser is not supported.\"        ,\"type\":\"Microsoft.SharePoint.Client.InvalidClientQueryException\",\"stacktrace\":\"     With CSOM:  //SP.SOD.executeOrDelayUntilScriptLoaded(getUserProperties, 'SP.UserProfiles.js'); function getUserProperties(targetUser) {      // get the target users domain name and account name.     var tUser = targetUser.substring(7);     // Get the current client context.     var clientContext = new SP.ClientContext.get_current();     //Get PeopleManager Instance     var peopleManager = new SP.UserProfiles.PeopleManager(clientContext);     // Get the properties to retrieve     var profilePropertyNames = ["PreferredName", "PictureURL"];     var userProfilePropertiesForUser = new SP.UserProfiles.UserProfilePropertiesForUser(         clientContext,         tUser,         profilePropertyNames);     // Get user profile properties for the target user     userProfileProperties = peopleManager.getUserProfilePropertiesFor(userProfilePropertiesForUser);     // Load the UserProfilePropertiesForUser object.     clientContext.load(userProfilePropertiesForUser);     //Execute the Query     clientContext.executeQueryAsync(onRequestSuccess, onRequestFail); }    I really don't understand where the issue is. Does anyone have an idea?
113235
I'm having trouble getting a custom claim attribute to come through in the id_token. I've got the scope set to openid and I've added the custom attribute to the Connected App (tenantId). I also tried implementing a connected app plugin and overiding the customAttributes method.  I checked Configure Id Token in the connected app config page and made sure custom claims was ticked (along with standard claims).  All of the above, and I keep getting back an id_token without the additional claim information. Have I missed anything? I know that i can make a call to the UserInfo endpoint, but i'm trying to avoid that.
19444
I'm building a small application in Go that will access Salesforce using REST. I chose to use the full OAuth webflow.   Documentation for the   I'm able to do the full flow when I use urlencoded form data in the token request (number 3 in the flow chart in the documentation).   func httpPostXCoded(c appengine.Context, theUrl string, attrs map[string]string, OAS OAuthSecurity) (body []byte, err error) {     var myUrlEncoded = ""     for key, val := range(attrs) {         if len(myUrlEncoded) &gt; 0 {             myUrlEncoded += "&amp;"         }         myUrlEncoded += key + "=" + url.QueryEscape(val)     }     req, err := httpRequest("POST", theUrl, bytes.NewReader([]byte(myUrlEncoded)))     if err != nil {         return     }     req.Header.Add("Content-Type", "application/x-www-form-urlencoded")     res, err := httpClient(c).Do(req)      // cut code }   I would however like to use a JSON-formatted request - I changed the code to look like this  func httpPostXCoded(c appengine.Context, theUrl string, attrs map[string]string, OAS OAuthSecurity) (body []byte, err error) {     var rbody []byte     var req *http.Request     if rbody, err = json.Marshal(attrs); err != nil {         return     }     req, err = httpRequest("POST", theUrl, bytes.NewReader(rbody))     if err != nil {         return     }     req.Header.Add("Content-Type", "application/json")     res, err := httpClient(c).Do(req)      // cut code }   Salesforce won't send me a token but an error message like this  {"error_description":"grant type not supported","error":"unsupported_grant_type"}   As you can see in the code snippet above I am setting the Content-Type to json. In both cases I have a key in the map called "format" with the value "json". The working urlencoded request will, correctly, give me json formatted data back.   An example of the json data I'm sending is   {"client_id":"","client_secret":"","code":"","format":"json","grant_type":"authorization_code","redirect_uri":"http://localhost:8080/callback"}   Please note some field has intentionally been emptied.
106624
I was just trying to find out if there was a public API for the Stack Overflow site. I want to know so that I could maybe use it for whatever it would let me use it for (like web-service or non browser application that can access Stack Overflow). I have a few (specific) ideas but I don't want anybody to get the jump on me before I have a chance to implement one of them ;). I know that is a little silly since there are a limited number of things that such a thing could be used for. It's not about $$ or copyright* or anything like that; I just want to do it my way first if possible. Anyhow I tried googling this and you can imagine how many results you get for "StackOverflow public api".
112425
I want to get the URL for my site collection. One way I thought I could do it was using the window.location in javascript and getting it that way.   I know that you can use ECMA script and the client object model to do this but unsure how.  I have tried:  var context = new SP.ClientContext; alert(context.get_url());   This is returning /  How would I get it to include the full URL? i.e. http://mysharepoint:29292/
72839
I've been trying to read through the SalesForce documentation on how to call a custom Method like this via cURL:  @RestResource(urlMapping='/Test/*') global with sharing class RestTest  {     @HttpGet     global static Account getAccount()     {         Account a = [select Id, Name from Account WHERE Name = 'wizzbang' limit 1];         return a;     } }   My gut tells me this should be something as simple as:  $ curl -i -H "Accept: application/json" -H "Content-Type: application/json"  -X GET https://mydomain.salesforce.com/services/apexrest/test/   But I get back that this is unauthenticated. I've gone through the guide and it says I have to setup a "connected app." I've done this...I think. But I'm not sure what my CallbackURL should be? Further, I don't get what I need to make my curl statement look like in order to call the service? Can someone explain what I need to do? This seems horribly overengineered.