当我们要调用Marketing Cloud的Api时,不管是SOAP还是REST都需要进行验权Authorization。
如果我们需要使用v2版本去获取token,我们需要传递5个参数,其中有3个参数是必须要传递的,2个可选参数,参考官网的文档Access Token for Server-to-Server Integrations | Marketing Cloud APIs and SDKs | Salesforce Developers
其中scope 默认不传就是拥有最高权限,相当于admin权限
account_id 建议传上,不传则默认是创建package的账号MID
Example Request
Host: https://YOUR_SUBDOMAIN.auth.marketingcloudapis.com POST /v2/token Content-Type: application/json { "grant_type": "client_credentials", "client_id": "", "client_secret": "", "scope": "email_read email_write email_send", "account_id": "" }
参数来源位置
Setup > Apps > Installed Packages >
Response Parameters
Example Response
HTTP/1.1 200 OK { "access_token":"69d8034fa6b281ffa1ed622144b66a61.a2894b8614772e68432f89ce29b66873example", "expires_in":1080, "token_type":"Bearer", "rest_instance_url":"mc563xyzgzs27c5t9-42k63xyzgm.rest.marketingcloudapis.com", "soap_instance_url":"mc563xyzgzs27c5t9-42k63xyzgm.soap.marketingcloudapis.com", "scope": "email_read email_write email_send" }
返回参数解释
access_token: 我们最需要的Token标签:Salesforce,Marketing,token,instance,Token,scope,email From: https://www.cnblogs.com/shinetech/p/17688744.html
exprires:过期时间,单位毫秒
token_type: Bearer,在之后请求API时需要和token拼接起来赋值给参数 Authorization
rest_instance_url: rest api请求地址
soap_instance_url: soap api请求地址
scope: token的权限范围
当你能获取到Token的时候你已经成功了一大步。