質問

I am creating a browser extension which posts to salesforce chatter using rest api.Once I get the access_token from OAuth user agent flow,I can not make call to rest services from javascript,due tobrowser same origin policy.I do not want to use a server as proxy,since I want to make the extension purely client side.

I tried JSONP workaround,but it only works for GET,I need POST to post a feed to salesforce chatter

is there a possible way.Please suggest some work around

役に立ちましたか?

解決

Maybe consider passing your call to a custom rest service in salesforce. Setup a global class with the @RestResource annotation, and then within that an doPost method to handle what you're passing, in your case to make the post.

You'll still need the Oauth step to retrieve token that is then passed in with the rest request via the Authorization : Bearer header message.

See a good post on this here https://wiki.developerforce.com/page/Creating_REST_APIs_using_Apex_REST

他のヒント

Since Salesforce '15 you are able to configure CORS. Therefor whitelist your app domain and you can do whatever you want. Does not solve the problem to obtain an access_token. The only approach to obtain an access_token purely by javascript is to use the User-Agent Flow since the access Token is passed as URL Part....

One option is to use site like http://www.ajax-cross-domain.com/

Here is good reference on this matter http://www.d-mueller.de/blog/cross-domain-ajax-guide/

Use jsforce, you will need a proxy due to the CORS problem, sorry.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top