-
Notifications
You must be signed in to change notification settings - Fork 142
OAuth 2.0 support #138
Comments
I second that. This SDK will be deprecated in starting August of this year. Although legacy apps will still work. Any new apps created will not work with this SDK starting in August. Anyone looking into this? We just started using Salesforce Marketing Cloud a few days ago. |
with a few tweaks i was able to fetch the access token in the sdk. REST is working, however my token is not accepted for SOAP: i wonder if the problem is that an access token is nu the same as an oauth token (should be right?), or something else is wrong.. |
the following xml envelope is created: <?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://exacttarget.com/wsdl/partnerAPI">
<SOAP-ENV:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
SOAP-ENV:mustUnderstand="1">
<wsse:UsernameToken>
<wsse:Username>*</wsse:Username>
<wsse:Password
Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">
*
</wsse:Password>
<wsse:Nonce>R8Wv/0QcgbmTyVVNdMCpYPLWsoTWqfUzfLT+IemzB64=</wsse:Nonce>
<wsu:Created
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
2019-04-19T09:05:32Z
</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
<oAuth xmlns="http://exacttarget.com">
<oAuthToken>
XXXX
</oAuthToken>
</oAuth>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns1:DefinitionRequestMsg>
<ns1:DescribeRequests>
<ns1:ObjectDefinitionRequest>
<ns1:ObjectType>List</ns1:ObjectType>
</ns1:ObjectDefinitionRequest>
</ns1:DescribeRequests>
</ns1:DefinitionRequestMsg>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope> |
Same here, I am getting the OAuth 2.0 token no problem and Rest is working fine. I am still trying to get it to work with Soap. I am using the Client ID and Client Secret from an installed pacakage instead of a username and password. |
I'm in the same boat. Hopefully there's a solution. I need to read/write to a data extension. |
Got a successful login with this envelope (make sure the request goes to soap endpoint):
now lets see if i can cleanly override the client. |
Thank you @jonathandezoete Any idea if there are any examples of making the requests the newer way in Postman or PHP? Right now, the SDK is dead to me without proper authentication (unless I'm missing something obvious), and I'm willing to custom code something, but having a hard time locating examples of a working authentication scheme for the OAuth 2.0 stuff in Postman while testing queries against the endpoints. We're doing everything through Marketing Cloud (formerly Exact Target), so I think I'm asking this in the right place. |
You can use the SDK no problem, just change the client. Havent had the time to do a clean fork, but if you substitute the ET_Client with the attached client php file.
For REST calls i just use guzzle. |
@jonathandezoete this is pretty cool, how much of the ET_Client did you have to modify? |
Not so much. See for yourself: https://www.diffnow.com/report/38kdi |
@jonathandezoete I dropped this file into the src folder, but I don't think it's autoloading. I see that your namespace is different. Is this meant to be put into another directory? Update. I ended up changing the namespace to FuelSdk since it's dropped in the same folder. You have a different class name so no need to create a new namspace. I'm guessing when you posted that it's plucked straight out of a project you're working on. Now I'm getting a new error. Undefined index: tenantKey in C:\wamp64\www\fuel-project\vendor\salesforce-mc\fuel-sdk-php\src\SQZL_ET_Client.php on line 75 Ok I got that fixed by adding a parameter to the function call and just set tenantKey to "whatever". I'm not sure what that's used for. So I also wasn't sure where to set the default WSDL save location so I set the first parameter to false. I had to change line 79 to use my specific wsdl endpoint with the specific stack so https://webservice.s7.exacttarget.com/etframework.wsdl So it seems that things are getting passed without failure, but I still don't think I'm connecting. I do a var_dump of $client and I don't see anything like an access token in there. I also don't know what to do with the next line $client->setInternalAuthToken('', "ACCESS_TOKEN"); |
@garek007 correct, didnt do anything besides copy it ;) |
the wdsl is fine. you should first get your access token and put that with the setInternalAuthToken().
|
Thanks @jonathandezoete I think I see what you're doing here. A few more questions and some things I don't understand. If I am using Guzzle and passing client_id and client_secret to the auth URL and then getting a token that I can then use in client, what would I still need to make the new SQZL_ET_Client call? I understand that I need to construct the object but I guess I'm wondering why we also need to pass the credentials to it as well? Seems like we're already doing it once with Guzzle. Secondly, I've been just instantiating a new object all over the place. I know this is not recommended, but I'm not sure how to simply reuse the access token for subsequent calls. |
Ok so I was able to connect using the code below and the getList request worked.
This is awesome @jonathandezoete thanks for sending this. The thing I still don't get, is why am I getting this error
and how do I persist my authorization for subsequent calls (ie page to page) without instantiating a new object each time? |
My colleague tidied things up a bit: @garek007 Thats probably because you are using a different tenantkey than is used in the constructor (the previously mentioned == null comparison). |
Thanks @jonathandezoete ! |
Thanks a lot @jonathandezoete and @garek007 ! But now I have this issue when I try to get list : $getResponse = $getList->get();
Do you have the same error ? |
Update: the baseSoapUrl wasn't correct |
Hi guys, I've created a fork here (please use v1.2.4) based on the branch Oauth2Implementation thanks to the work of @sfcbetiuc All you have to do is pass a new parameter "useOAuth2Authentication" and set true as value.
|
this is awesome! thanks @pfortin-expertime |
That's awesome! Anyway we can get it merged into this repository? |
3 years later and I find this. I'm doing well with the api, but looking at ET_Client.php and I can't figure out for the life of me what tenantKey is supposed to be. I've tried it with my subdomain, MID, nothing works. Looking at ET_Client.php I don't even see how/where it is set. Regarding the if ($this->tenantTokens[$tenantKey] == null) statements, I did change at least one to isset() in my forked repo. |
Hi,
Looks like SalesForce Marketing Cloud soon defaults to OAuth 2.0 without the possibility of using legacy authentication https://jmp.sh/tcbTj8c
Is there any plan to support packages created using OAuth 2.0? Currently getting: https://jmp.sh/5jdmXSk & is unable to find any documentation that would allow me to use OAuth 2.0
The text was updated successfully, but these errors were encountered: