You need to sign in to do that
Don't have an account?
Is it possible to do headless OAuth 2.0
I realize that OAuth is most useful when the user is working in a web application or desktop application that redirects to the Salesforce login screen to authenticate. However, to start testing the wonders to the new REST API, I wanted to write a simple program without a front-end but would still allow me to authenticate using OAuth2. Once authorized I would be able to call the normal REST commands. I can't figure out how to login programmatically without using proxy classes for the SOAP API.
Is it possible to authenticate with only GETs and POSTs using Salesforce's OAuth2 service? I'm primarily using Java and would like to use HttpGet and HttpPost to authenticate before issuing REST commands. Any samples are appriciated. I would obviously just put my Salesforce login credentials in my code for now. This is just for testing. I would like to test without having to run a full-blown web application for authentication purposes.
Andrew
You can use the oAuth2 username and password flow, see https://na3.salesforce.com/help/doc/en/remoteaccess_authenticate.htm
All Answers
You can use the oAuth2 username and password flow, see https://na3.salesforce.com/help/doc/en/remoteaccess_authenticate.htm
Thanks. That looks to be what I'm looking for. However, for the life of me, I can't seem to authorize by following those directions. I always get the same error.
I'm using the following Java code to authorize:
The body contents doesn't seem to have any affect. With or without the body, I get the same error:
Any help is greatly appreciated. I feel like I'm really close the OAuth 2.0 Username-Password flow is the right authentication flow to follow.
Andrew
I seem to fix part of the problem by fixing the post url. I was incorrectly targeting the autherize path when I wanted the 'token' path. With that change, I get a different error response.
The new error is:
Anyone know how to solve this? The documentation states I need to specify 'password' as the grant_type.
Andrew
The POST needs to be form encoded parameters, not a json payload. there are examples (using curl) in the REST forum.
It worked beautifully. Thanks for all your help. For anyone else, here how you do the OAuth 2.0 Username-Password flow authentication.
Thanks.