相关疑难解决方法(0)

"代码":403和"原因":在谷歌加上传文件时"禁止"例外

我试图在谷歌+上传媒体文件,我已经在谷歌控制台创建了客户端ID.我上传方法表格
附加媒体

认证

在运行应用程序时,我遇到异常

 Media result = null;
                    try {
                        result = insertRequest.execute();
                    } catch (IOException e1) {
                        // TODO Auto-generated catch block
                        // e1.printStackTrace();
                        Log.e("result exception", "" + e1);
                    }
Run Code Online (Sandbox Code Playgroud)

例外是:

 12-09 18:49:20.983: E/result exception(26301):com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
12-09 18:49:20.983: E/result exception(26301): {
12-09 18:49:20.983: E/result exception(26301):   "code" : 403,
12-09 18:49:20.983: E/result exception(26301):   "errors" : [ {
12-09 18:49:20.983: E/result exception(26301):     "domain" : "global",
12-09 18:49:20.983: E/result exception(26301):     "message" : "Forbidden",
12-09 18:49:20.983: E/result exception(26301):     "reason" : "forbidden"
12-09 …
Run Code Online (Sandbox Code Playgroud)

android file-upload google-plus

9
推荐指数
2
解决办法
9327
查看次数

Gmail-API JAVA客户端发送电子邮件权限不足

我正在尝试通过Gmail发送电子邮件。我几乎将所有范围授予该服务。但是我仍然收到错误消息,权限不足。

Exception in thread "main" com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden

{
  "code" : 403,
  "errors" : [ {
    "domain" : "global",
    "message" : "Insufficient Permission",
    "reason" : "insufficientPermissions"
  } ],
  "message" : "Insufficient Permission"
}

    at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:145)
    at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113)
    at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:40)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse(AbstractGoogleClientRequest.java:321)
    at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1056)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:419)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469)
    at GmailQuickstart.main(GmailQuickstart.java:133)
Run Code Online (Sandbox Code Playgroud)

:运行失败

private static final List<String> SCOPES =
    Arrays.asList(GmailScopes.GMAIL_LABELS, GmailScopes.GMAIL_COMPOSE, GmailScopes.GMAIL_INSERT, GmailScopes.GMAIL_MODIFY, GmailScopes.GMAIL_READONLY, GmailScopes.MAIL_GOOGLE_COM);

static {
    try {
        HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport();
        DATA_STORE_FACTORY = new FileDataStoreFactory(DATA_STORE_DIR);
    } catch (Throwable t) { …
Run Code Online (Sandbox Code Playgroud)

java email oauth-2.0 gmail-api

5
推荐指数
1
解决办法
3344
查看次数

尝试使用Java中的Gmail API发送电子邮件时出错

我想使用Gmail API(而不是JavaMail)发送电子邮件.我在论坛上阅读了很多类似的主题,但我还是有问题.

首先我读到这个:https://developers.google.com/gmail/api/guides/sending

我发现了一些方法:MimeMessage createEmail,Message createMessageWithEmail和Message sendMessage

然后我注意到我没有对象Gmail服务的定义,所以我需要一个GmailQuickstart类,它位于:https://developers.google.com/gmail/api/quickstart/java

我实现了:类GmailQuickstart,方法Credential authorize()和方法Gmail getGmailService()

最后我写了一篇主要内容:

public static void main(final String[] args) throws MessagingException, IOException {
    String APPLICATION_NAME = "gmailProject";
    HttpTransport HTTP_TRANSPORT = new NetHttpTransport();
    JsonFactory JSON_FACTORY = new JacksonFactory();
    Credential credential = GmailQuickstart.authorize();

    String to = "frommail@gmail.com";
    String from = "tomail@gmail.com";
    String subject = "Subject";
    String bodyText = "Body";
    MimeMessage emailcontent = createEmail(to, from, subject, bodyText);
    createMessageWithEmail(emailcontent);
    Gmail service = new com.google.api.services.gmail.Gmail.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential)
            .setApplicationName(APPLICATION_NAME).build();
    sendMessage(service, "me", …
Run Code Online (Sandbox Code Playgroud)

java email gmail gmail-api

3
推荐指数
1
解决办法
1855
查看次数

标签 统计

email ×2

gmail-api ×2

java ×2

android ×1

file-upload ×1

gmail ×1

google-plus ×1

oauth-2.0 ×1