I want to use OpenId for Salesforce authentication.

I have done the following:

Now I test the OpenId authentication and it works. Finally I want to use the openId response access token for salesforce REST API, but it does not work. I get:

    "message": "This session is not valid for use with the REST API",
    "errorCode": "INVALID_SESSION_ID"

Could someone tell me how I can use the openId access token for Rest API?

Thanks, mg92

1 Answer 1


I forgot to add the scope parameter "api" into my scope list.

Now I can do REST API calls.

services.AddAuthentication().AddOpenIdConnect(o =>
 o.ClientId = "XYZ";
 o.ClientSecret = "ABC";
 o.Authority = "https://test.salesforce.com";
 o.ResponseType = OpenIdConnectResponseType.Code;
 o.GetClaimsFromUserInfoEndpoint = true;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.