google cloud api,谁用谁傻逼
1. 如果smtp接入完全不用这么麻烦,而且没啥区别
2. 具体过程忘了,代码如下
记得在目录下添加credentials, 依稀记得也可以通过环境变量指定位置
Linux、macOS:$HOME/.config/gcloud/application_default_credentials.json
* Windows:%APPDATA%\gcloud\application_default_credentials.json
credentail样例如下
{
"type": "service_account",
"project_id": "metmake-emai",
"private_key_id": "91ef937b8f00d13",
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvgIBADANBgCBak\n-----END PRIVATE KEY-----\n",
"client_email": "email-287@metmake-emai.iam.gserviceaccount.com",
"client_id": "114006151",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/email-287%40metmake-emai.iam.gserviceaccount.com"
}
父类maven
<google-auth-library-oauth2-http.version>1.3.0</google-auth-library-oauth2-http.version>
<google-api-services-gmail.version>v1-rev110-1.25.0</google-api-services-gmail.version>
<javax-mail.version>1.4</javax-mail.version>
<!-- google email -->
<dependency>
<groupId>com.google.auth</groupId>
<artifactId>google-auth-library-oauth2-http</artifactId>
<version>${google-auth-library-oauth2-http.version}</version>
</dependency>
<!-- google email https://mvnrepository.com/artifact/javax.mail/mail -->
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>${javax-mail.version}</version>
</dependency>
<!-- google email https://mvnrepository.com/artifact/com.google.apis/google-api-services-gmail -->
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-gmail</artifactId>
<version>${google-api-services-gmail.version}</version>
</dependency>
子类maven
<!-- google email -->
<dependency>
<groupId>com.google.auth</groupId>
<artifactId>google-auth-library-oauth2-http</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.mail/mail -->
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.apis/google-api-services-gmail -->
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-gmail</artifactId>
</dependency>
发表回复