Using Google API's for one's own account without OAuth


Specifically, I'd like to use the Gmail API to access my own mail <strong>only</strong>. Is there a way to do this without OAuth and just an API key and/or client id and secret?

Using an API key like:

require('googleapis').gmail('v1').users.messages.list({ auth: '<KEY>', userId: '<EMAIL>') });

yields the following error:

{ errors: [ { domain: 'global', reason: 'required', message: 'Login Required', locationType: 'header', location: 'Authorization' } ], code: 401, message: 'Login Required' }

I suppose that message means they want a valid OAuth "Authorization" header. I would do that but I suppose that's not possible without presenting a webpage.


The strict answer to "Is there a way to do this without OAuth and just an API key and/or client id and secret?" is no.

However, you can achieve what you are looking for using OAuth. You simply need to store a Refresh Token, which you can then use any time to request an Auth Token to access your gmail.

In order to get the refresh token, you can either write a simple web app to do a one time auth, or follow the steps here <a href="https://stackoverflow.com/questions/19766912/how-do-i-authorise-a-background-web-app-without-user-intervention-canonical/19766913#19766913" rel="nofollow">How do I authorise an app (web or installed) without user intervention? (canonical ?)</a> which allows you to do the whole auth flow using the Oauth Playground.


  • Application.AddMessageFilter - how to read exactly what keys were pushed?
  • Bundler using old version
  • JsonMappingException: Can not deserialize instance of java.lang.Integer out of START_OBJECT token
  • PHP Copy function not working
  • Change device language on Android 6.0 (Android M)
  • Invert string in Rust
  • How to concat Pandas dataframe columns
  • how to get username into sql trigger when multiple users signed on from asp membership
  • jwtBearer bearer token with rc-1 update to ASP.Net 5
  • Does Mobilefirst provide a provision to access web services directly?
  • How to revert to previous XCode version?
  • Should I or shouldn't I use the CachingConnectionFactory with hornetq 2.4.1
  • How do I access an unhandled exception in an MVC Error view?
  • Make VS2015 use angular-cli ng at build time in a .NET project
  • Email verification using google app script and google forms
  • Why value captured by reference in lambda is broken? [duplicate]
  • Email format validation in mvc3 view
  • java.lang.NoClassDefFoundError: com.parse.Parse$Configuration$Builder on below Lollipop versions
  • Where to put my custom functions in Wordpress?
  • sending/ receiving email in Java
  • Numpy divide by zero. Why?
  • Codeigniter doesn't let me update entry, because some fields must be unique
  • Hits per day in Google Big Query
  • How do you join a server to an Active Directory (domain)?
  • Why joiner is not used after Sequence generator or Update statergy
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • Linking SubReports Without LinkChild/LinkMaster
  • EntityFramework adding new object to nested object collection
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass
  • Easiest way to encapsulate a HTML5 webpage into an android app?
  • Does armcc optimizes non-volatile variables with -O0?
  • Busy indicator not showing up in wpf window [duplicate]
  • Recursive/Hierarchical Query Using Postgres
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?
  • java string with new operator and a literal