“This app would like to: Have offline access” when access_type=online

I think G does this when your app requests a token and there is still a valid access or refresh token for the user for the scopes in question. The solution is to revoke tokens when you’re done with them (either on user logout or immediately after authenticating the user) by issuing this request: https://accounts.google.com/o/oauth2/revoke?token={token} … Read more

Can a public IP address be used as Google OAuth redirect URI?

This is not currently supported. I filed a feature request and will update on progress. Update: Essential app verification activities have continued to make support of IP address-based apps unlikely. These verification activities are necessary to provide protections against abuse of user accounts. In addition, the cost of setting up dedicated domains has been reduced … Read more

Can we access GMAIL API using Service Account?

I use the following C# code for accessing Gmail from Service Account String serviceAccountEmail = “999999999-9nqenknknknpmdvif7onn2kvusnqct2c@developer.gserviceaccount.com”; var certificate = new X509Certificate2( AppDomain.CurrentDomain.BaseDirectory + “certs//fe433c710f4980a8cc3dda83e54cf7c3bb242a46-privatekey.p12”, “notasecret”, X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.Exportable); string userEmail = “[email protected]”; ServiceAccountCredential credential = new ServiceAccountCredential( new ServiceAccountCredential.Initializer(serviceAccountEmail) { User = userEmail, Scopes = new[] { “https://mail.google.com/” } }.FromCertificate(certificate) ); if (credential.RequestAccessTokenAsync(CancellationToken.None).Result) { GmailService … Read more

How to use Google Login API with Cordova/Phonegap

Google has dropped support for the accepted answer above! After April 20th 2017 use of the In-App browser as described by @Deep Mehta will no longer be supported. If you use the accepted answer then it is going to start failing very soon. Here’s Google’s post about the change: https://developers.googleblog.com/2016/08/modernizing-oauth-interactions-in-native-apps.html Luckily there’s a new plugin … Read more

Google OAuth using domain wide delegation and service account

Answer: You need to pass your Service Account private key obtained from the GCP console to your JWT Client, and specify which user you wish to impersonate as a subject. Code: After getting your private key, you need to pass this into your JWT Client before authorisation: let google = require(‘googleapis’); let privateKey = require(“./privatekey.json”); … Read more

How to use the Gmail API, OAuth2 for Apps Script, and Domain-Wide Delegation to set email signatures for users in a G Suite domain

This method uses the Gmail API, the OAuth2 for Apps Script library, and “Domain-wide Delegation of Authority”, which is a way for G Suite admins to make API calls on behalf of users within their domain. Step 1: Make sure the OAuth2 For Apps Script library is added to your project. Step 2: Set up … Read more