Using gmail API with InboxSdk

1,526 views
Skip to first unread message

Ori

unread,
Dec 4, 2016, 5:05:11 PM12/4/16
to InboxSDK
 .Hey ,I need some functionally of Gmail API that not exists in inboxSdk....like getting attachment etc
 The problem that I am not success to  get anything from the API
I follow this guide step by step and take from there the background.js file


I set the background file in the manfiest and create a client_id in google console .. Then I try in content.js page to get for example a message like this


function getMessage(userId, messageId, callback) {

  var request = gapi.client.gmail.users.messages.get({

    'userId': userId,

    'id': messageId

  });

  request.execute(callback);

}



But , When I run it I get error of undefined of the gapi 
i try many solutions but it's always undefined on the gapi

Possibly uncaught promise rejection ReferenceError: gapi is not defined(…)




I must some help...

Thanks all


geet mehar

unread,
Dec 5, 2016, 7:06:50 AM12/5/16
to InboxSDK
You have to load gmail.api in extension file system before using it.

Pavel Savchenko

unread,
Dec 5, 2016, 8:46:06 AM12/5/16
to InboxSDK
Here is one way to include gmail api javascript client in the extension:


Let us know if you figure out a better way.

Ori

unread,
Dec 5, 2016, 9:44:48 AM12/5/16
to InboxSDK

Hey and thank to both of you for your answers.
I done exactly what have in this guide .... and I also set it in the manifest...this is my manifest... Am i doing something wrong that it's not recognize this?

{
  "name": "Example Gmail Extension",
  "description": "Example extension showing use of the Streak Gmail SDK",
  "version": "0.1",
  "content_scripts": [
    {
      "matches": [
      ],
      "js": ["inboxsdk.js","content.js"],
      "run_at": "document_end"
    }
  ],  
     "background": {
    "scripts": ["base64.js", "background.js"]
  },
  "content_security_policy": "script-src https://*.google.com 'unsafe-eval'; object-src 'self'",
  "oauth2": {
    "scopes": [
    ]
  },

  "permissions": [
        "background",
        "identity",
        "notifications",
        "storage",
        "alarms",
        "https://*.googleusercontent.com/*",
  ],
  "manifest_version": 3
}




Thanks all again !


בתאריך יום שני, 5 בדצמבר 2016 בשעה 15:46:06 UTC+2, מאת Pavel Savchenko:

geet mehar

unread,
Dec 5, 2016, 12:33:36 PM12/5/16
to Ori, InboxSDK
Try including gmailapi javascript file in manifest under content script.

--
You received this message because you are subscribed to a topic in the Google Groups "InboxSDK" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/inboxsdk/2WtqfWOQ5To/unsubscribe.
To unsubscribe from this group and all its topics, send an email to inboxsdk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/inboxsdk/6b98da73-1104-41dc-b4ce-864b9c71196a%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Regards,
Geet Mehar

Ori

unread,
Dec 6, 2016, 5:47:30 AM12/6/16
to InboxSDK, oria...@gmail.com
 :Hey I try to set the gmail api library in the content script but it's doesnt help .. I still have a error
Uncaught TypeError: gapi.loaded_0 is not a function(…)
Uncaught (in promise) TypeError: Cannot read property 'gmail' of undefined(…)

 When I in bakcground.js file I sucess to do calls for gmail api and it's recgonize me the methods....but in the content.js of inboxSDK still this error.....
What I could do? I try almost everything

tnx all!

בתאריך יום שני, 5 בדצמבר 2016 בשעה 19:33:36 UTC+2, מאת geet mehar:
To unsubscribe from this group and all its topics, send an email to inboxsdk+u...@googlegroups.com.



--
Regards,
Geet Mehar
Message has been deleted

Ori

unread,
Dec 7, 2016, 3:46:07 AM12/7/16
to InboxSDK
I upload my question also to stackoverflow .. If someone have any idea ...


tnx!
Reply all
Reply to author
Forward
0 new messages