Gmail OAuth Swift

Skip to first unread message

Daniel James

Jul 21, 2020, 9:23:47 AM7/21/20
to Google APIs Client Library for Objective-C
I'm trying to get the messages list from gmail with Google API. So far I have implemented the AppAuth process with
"" and I have my token response.

What I am trying to do now is 

func listInboxMessages() {
let gmailService = GTLRGmailService.init()

let listQuery = GTLRGmailQuery_UsersMessagesList.query(withUserId: "me")
listQuery.labelIds = ["INBOX"]

// let authorizer = GIDSignIn.sharedInstance()?.currentUser?.authentication?.fetcherAuthorizer()
// gmailService.authorizer = authorizer

gmailService.executeQuery(listQuery) { (ticket, response, error) in
    if response != nil {
        print("Response: ")
    } else {
        print("Error: ")
But the commented lines comes from GoogleSign In. Which is not present in my project. Withouth them I
 "Expected OAuth 2 access token, login cookie or other valid authentication credential"
How can I obtain the messages list (gmail) with my token? I'm also trying to study the official documentation or "" but I can't find something helpful

Jul 21, 2020, 9:47:39 AM7/21/20
to Google APIs Client Library for Objective-C
Wiki also mentioned you can use to use AppAuth-iOS instead of GoogleSignin.  If you want to manually build up the integration, look at that project for bridging things over into an Authorizer to use the the GTMSessionFether used by GTLR.


Aniket Kumar Singh

Sep 12, 2020, 10:14:47 AM9/12/20
to Google APIs Client Library for Objective-C
Reply all
Reply to author
0 new messages