7

I am using DotNetOpenAuth libraries to implement OAuth 2.0 client side to communicate with SalesForce authorization server. I have finished first two steps of OAuth 2.0 communication that ends with obtaining of access token from SalesForce authorization server.

When I get authentication response from SF with access token I can not find Id, that should contain full URL address to the specific user details. I am missing something ?

Here it is the URL from the http header when I have been redirected back from SF to the consumer application :

GET /Account/RegisterSalesForcelLogin.aspx?code=aPrxMZkm7lCkgfRmFY90tEF1_Wk_Fn0IN6iDVcy3u6joOHoaEdOP9NiQcHvbQT71SJhh0zWPiQ%3D%3D&state=Ot88XPwqvlsK-yE0zrrFmw HTTP/1.1

In code, I am consuming AuthorizationState object from DotNetOpenAuth libraries after authorization response is received. It does not contain extra data except access token, refresh token, etc. When I go deeper in their code I saw that initial response from SF does not contains extra data, not at all.

Here is the code for sending initial code to SalesForce :

    public void InitCall()
    {
        AuthorizationServerDescription authServerDescription = new AuthorizationServerDescription();
        authServerDescription.AuthorizationEndpoint = new Uri(@"https://login.salesforce.com/services/oauth2/authorize");
        authServerDescription.TokenEndpoint = new Uri(@"https://login.salesforce.com/services/oauth2/token");
        authServerDescription.ProtocolVersion = ProtocolVersion.V20;

        WebServerClient newClient = new WebServerClient(authServerDescription, clientID, clientSecret);
        //newClient.ClientCredentialApplicator = ClientCredentialApplicator.PostParameter(clientSecret);

        var uri = "https://sfconsumer.com:50002/Account/RegisterSalesForcelLogin.aspx";
        IEnumerable<string> scopes = new List<string> { "id", "web", "api", "refresh_token" };
        client.RequestUserAuthorization(scopes, new Uri(uri));
    }
  • Welcome to SFSE @Rastko. One of the ideas of this site is that your questions and the answers it gets will be a guide to other users down the line. Things gets a little tricky when you ask two questions at the same time. I've edited out your second question, if you could please ask it again as a second question I'm sure you'll get a good answer. Other tips, include the raw output from the authentication response so users can tell what you might be missing. – Ralph Callaway Jun 4 '13 at 12:34
  • can you please post the URL params (excl. client id and secret) u use to call the Auth service – Seb Wagner Jun 4 '13 at 12:38
2

DotNetOpenAuth does not enable you to gather extra data after the final OAuth 2.0 response from authorization server. You need to make extra call over SOAP or REST API to get that data.

I changed this library with my code.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.