Node.js google drive api - authorize without consent screen

后端 未结 2 1057
时光说笑
时光说笑 2021-01-06 06:08

I\'m interesting is this possible to use Google Drive API without consent screen in Node.js app?

  • I want using only account where I enable app engine. Api must
相关标签:
2条回答
  • 2021-01-06 06:21

    What you are looking for is called a service account. Service accounts are dummy users that have their own drive account. They can also be granted permission to your personal drive account by sharing a folder or file with them like you would any other user. Because service accounts are preauthorized there is no consent screen.

    I am not a Node.js developer but i found this. Accessing Google API using Service Account in Node.js

    var CLIENT_ID = env.googleapis.client_id;
    var CLIENT_SECRET = env.googleapis.client_secret;
    var oauth2 = new googleapis.OAuth2Client(CLIENT_ID, CLIENT_SECRET, 'postmessage');
    
    var SERVICE_ACCOUNT_EMAIL = 'email@serviceaccount.com';
    var SERVICE_ACCOUNT_KEY_FILE = '/path/to/decrypted/key/file';
    var jwt = new googleapis.auth.JWT(
            SERVICE_ACCOUNT_EMAIL,
            SERVICE_ACCOUNT_KEY_FILE,
            null,
            ['https://www.googleapis.com/auth/analytics.readonly']);
    

    I also have a tutorial on service accounts if you are interested in understanding how they work and how to set one up. Google developer console service account

    0 讨论(0)
  • 2021-01-06 06:31

    Do not use a Service Account. It doesn't do what you think it does. What you need is a stored Refresh Token for your Google Account. I've set out all of the steps at How do I authorise an app (web or installed) without user intervention? (canonical ?) , including sample JavaScript which will run under node.

    0 讨论(0)
提交回复
热议问题