function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ashwini ZineAshwini Zine 

Facing error as "This session is not valid for use with the REST API" while integration with PHP platform

Hello,

I want to create lead record using integration of php platform. I have written rest API for that. The code is working fine when tested on workbench. But now I have integrated salesforce with PHP platform. I do recieved the correct access code,client_id,client_secret,username,password, security token,Authorization:OAuth . I am sending the response in JSON format. But I am facing the issue like :
    [0] => Array
        (
            [message] => This session is not valid for use with the REST API
            [errorCode] => INVALID_SESSION_ID
        )

Any help is appreciated. Thanks in advance!

Regards,
Ashwini

Best Answer chosen by Ashwini Zine
Ashwini ZineAshwini Zine

Hey Raj Vakati,

Thanks for your response!

Actually I had solved the error, I had missed two factor authentication setting in session setting.

All Answers

Raj VakatiRaj Vakati
You have to add the API in Selected OAuth Scopes 

Go to the connected app and you can able to see the different OAuth scope

Access and manage your data (api)
Allows access to the logged-in user’s account using APIs, such as REST API and Bulk API. This value also includes chatter api, which allows access to Chatter REST API resources.

User-added image
Ashwini ZineAshwini Zine

Hey Raj Vakati,

Thanks for your response!

Actually I had solved the error, I had missed two factor authentication setting in session setting.

This was selected as the best answer
SFDC AlexSFDC Alex

Hi, 

Even I am getting this error. Can someone please tell me where I can get this option? I am not able to find it.

Thanks!

Kalyan_PKalyan_P
I received the same error when I enabled the 
Profile -> Session Settings -> "Session Security Level Required at Login-High Assurance". I believe when you try to use API logins the session required MFA related token also to access the Resource Server. When I removed the High Assurance then it working fine I believe this setup is intended for User-Agent or WebServer flow not for Server to Server connection using JWT Barear flow or UserName password flow. 
Kalyan_PKalyan_P
User-added image
Nikhil_ReddyNikhil_Reddy
Use any API client permission in the system permissions of a profile or permission set will resolve this issue