Related Articles

Responses

  1. Hi Avnish,

    I did the same way you have mentioned above but I am getting bad request while accessing the oauth token. I tried in all possible ways to solve this but no luck. Can you please help me to solve this issue?

    When I check logs, I see below error -

    CALLOUT_REQUEST|[22]|System.HttpRequest[Endpoint=https://democlass1-dev-ed.my.salesforce.com/services/oauth2/token, Method=POST]
    CALLOUT_RESPONSE|[22]|System.HttpResponse[Status=Bad Request, StatusCode=400]

    Thanks,

    Raji M

  2. Hello

    In ReturnAccessToken method you have to pass reqbody value as following

    String reqbody = 'grant_type=password' + '&client_id='+clientId +
    '&client_secret='+clientSecret + '&username='+username + '&password='+password;

    For me its working when i change like above code

    Thanks

    Siri Chandana

  3. hello

    for password field you have to pass

    password = password+security token (Not Access token)

    Creation of Security token :

    Go to your org -> My Settings -> search (Reset My Security Token) ->Check your registered mail -> there you get Security Token