Unsupported Grant Type Salesforce OAUTH2

前端 未结 1 885
轮回少年
轮回少年 2021-01-27 10:22

I am using VBA to get authorization in Salesforce and then ultimately want to run a Salesforce report and dump the results in Excel. I have written the following to handle the a

1条回答
  •  无人及你
    2021-01-27 11:05

    You're using "Username-password flow". All params in the URL, without displaying a popup letting user type his credentials straight to SF (ideally if there's user interaction rather than backend systems talking to each other you're supposed to use another OAuth flow so your app doesn't handle passwords, can't leak them).

    Troubleshooting:

    1. Make sure username in your request is encoded. At very least put %40 instead of @. If your attempt doesn't even show up in user's login history - wrong / incorrectly encoded username.
    2. You might need the security token also silently appended to the password (again, look into user's login history, maybe there's "Failed: API security token required").
    3. If you use Setup -> My Domain feature, check whether you're allowed to log in from generic login.salesforce.com. Maybe your organisation disabled it and allows only the branded login domain (will impact API access too). Or maybe your admins allow logging in only from certain IPs...
    4. Also you don't need to add Authorization: Basic + username & pass in this call, you pass it in POST's payload and that's enough.

    If you have Postman, curl, SoapUI or any client like that - might help before jumping straight to VBA?

    This works for me (with Content-Type: application/x-www-form-urlencoded header)

    0 讨论(0)
提交回复
热议问题