Skip to content

Support BackendApplicationClient #152

Open
@avizelo

Description

@avizelo

Does requests-oauthlib supports using service account (BackendApplicationClient)?
Specifically, I would like to implement the following example were the authentication to google drive API is done via a service account (as the google apiclient lib is not supported for python3)

The below example uses apiclient and taken from https://developers.google.com/drive/web/service-accounts

import httplib2
import pprint
import sys

from apiclient.discovery import build
from oauth2client.client import SignedJwtAssertionCredentials

"""Email of the Service Account.
SERVICE_ACCOUNT_EMAIL = '@developer.gserviceaccount.com'

""" Path to the Service Account's Private Key file.
SERVICE_ACCOUNT_PKCS12_FILE_PATH = '/path/to/<public_key_fingerprint>-privatekey.p12'

def createDriveService():
"""Builds and returns a Drive service object authorized with the given service account.

Returns:
Drive service object.
"""
f = file(SERVICE_ACCOUNT_PKCS12_FILE_PATH, 'rb')
key = f.read()
f.close()

credentials = SignedJwtAssertionCredentials(SERVICE_ACCOUNT_EMAIL, key,
scope='https://www.googleapis.com/auth/drive')
http = httplib2.Http()
http = credentials.authorize(http)

return build('drive', 'v2', http=http)

Thanks,
Avi

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions