Salesforce OAuth 2.0 User

I've been trying to test out the OAuth flow on my connected app, but I get the following behaviour:

  • Authorize the app:

    https://login.salesforce.com/services/oauth2/authorize?response_type=token& client_id=theclientid&redirect_uri=https%3A%2F%2Fmysite.com

  • Login to Salesforce, Click "Allow" on "RemoteAccessAuthorizationPage"

  • Page redirects to mysite.com. Using "access_token" in URL, make the following cURL call

    curl -X GET https://na1.salesforce.com/services/data/v28.0/sobjects/Account -H 'Authorization: Bearer thetoken' -H 'X-PrettyPrint:1'

  • Response:

    { "message" : "Session expired or invalid", "errorCode" : "INVALID_SESSION_ID" }

  • I've also tried the "OAuth Refresh Token Process" with the token I get from 1. however that also fails with:

    { error_description: "expired access/refresh token" error: "invalid_grant" }

    I tried converting the %21 to ! in the URL encoded access_token, but that didn't help.

    Can anyone suggest what I'm doing wrong?


    Figured it out, the cURL call was malformed. I had to replace the '%21' with '!' and also change the header from 'Bearer' to 'OAuth'.


    It looks like you're missing a step after getting to

    https://login.salesforce.com/services/oauth2/authorize?response_type=token& client_id=theclientid&redirect_uri=https%3A%2F%2Fmysite.com
    

    You'll need to enter the login details and then you'll get redirected to the callback url you set up in your connected app settings which will include the access token you can use to authenticate your app.

    链接地址: http://www.djcxy.com/p/68438.html

    上一篇: 请求OAUTH令牌调查猴子v3时缺少参数

    下一篇: Salesforce OAuth 2.0用户