CakePHP-Copula / Copula

(Previously ApiDatasources) An abstract datasource for use in conjunction with specific api datasources
55 stars 23 forks source link

Need better documentation for customizing API requests #7

Open abalonepaul opened 11 years ago

abalonepaul commented 11 years ago

I am creating a new api plugin for salesforce. I was having trouble authenticating because Salesforece require request_type in the authorization call.

I added the response_type to the database config and then added this on line 247 of OauthComponent

        if (!empty($this->_config[$this->useDbConfig]['response_type'])) {
            $redirect .= '&response_type=' . $this->_config[$this->useDbConfig]['response_type'];
        }
ProLoser commented 11 years ago

Think you could open a pull request?

ProLoser commented 11 years ago

I would also recommend throwing the plugin into a repo online so I can help you out with it and link people to it!

abalonepaul commented 11 years ago

I can't release the plugin as it is for a client, and I don't have the authority to release it as of yet. I will checkout the HttpSocketOauth and do a pull request.

Take care,

Paul

abalonepaul commented 11 years ago

This apparently worked for the authorization, but now it sends it on other calls as well. I'm having a hell of a time trying to get this to work with Salesforce. It appears as though their flow is considerably different. The rest url is generated dynamically and returned with the access token. The REST calls do not need the client_id or secret. They only need the Authorization header set. The format is simply "Oauth access_key"

ProLoser commented 11 years ago

You are expected to extend the ApisSource and define your own class. If you do, you can override the methods (and call the parent method from within) or you could simply define a beforeRequest() method to make any last-minute modifications.

Again, if you had some code online to review (just the datasource only) this would be a lot easier. Are you creating a separate plugin/datasource/config file that extends this one? Or are you just modifying this directly and/or modifying the request object directly?

abalonepaul commented 11 years ago

I think I got it worked out. I definitely had to override some methods. I'll try to push the basic plugin when I wrap up the project.

ProLoser commented 11 years ago

Are you leveraging an API config map or are you just putting in the paths directly?

abalonepaul commented 11 years ago

I did both. I used the path directly until I figured it out. Now I am using a config may. I was not getting the results I wanted from some of the calls, so I ended up using SOQL and currently have that working in a rudimentary fashion. I am going to pull some of the query builder methods to build and pass SOQL queries.

tenebrousedge commented 11 years ago

This does not appear to be an issue with the plugin itself. There are a number of ways to customize API requests. I am leaving this issue open and changing the title to reflect a need for better documentation regarding this.

abalonepaul commented 11 years ago

You should be able to close this. I was able to make it work without modifying.