Skip to main content

Hi,

 

I have an embedded login working with my website and I am getting an access token for a community user login.that I can use to add the Bearer token to a request header in an Ajax call using straight javascript.  I also created a Salesforce REST api accepting a POST method.  When I call the REST api from the client browser including the Authorizaion header with the bearer token the REST API doesn't use the token.  The REST API functions fine but in the REST API adding UserInfo.getUsername(); I can see the API is running as the Community Guest User account and not the User account of the bearer token. I also needed to add the REST API to the Guest user profile. 

 

Is it possible to pass a Bearer token to a Salesforce REST APi and have the API authenticate with the token so it runs in the context of the token represented user?  Salesforce help indicates this should work but I'm not having much luck.

 

Thank You,

Brian

5 comentarios
  1. 25 ago 2020, 00:49
    @Samuel Rosen

    The access_token in the widget is encoded. I used the decodeURIComponent() function passing in the token when adding the token to the request header and that fixed the issue.

    Thank You,

    Brian

0/9000