-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SFR-2304_Add Airtable API Authentication Flow (#446)
* SFR-2304_Add Airtable API Authentication Flow * Added Airtable integration to util function * fixing newlines --------- Co-authored-by: Dmitri <[email protected]> Co-authored-by: kyle <[email protected]>
- Loading branch information
1 parent
b4ce653
commit edda0ce
Showing
3 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import os | ||
from ..util import airtable_integration | ||
|
||
from ..core import CoreProcess | ||
from logger import create_log | ||
|
||
logger = create_log(__name__) | ||
|
||
class PublisherBacklistProcess(CoreProcess): | ||
def __init__(self, *args): | ||
super(PublisherBacklistProcess, self).__init__(*args[:4]) | ||
|
||
self.ingest_offset = int(args[5] or 0) | ||
self.ingest_limit = (int(args[4]) + self.ingestOffset) if args[4] else 5000 | ||
self.full_import = self.process == 'complete' | ||
|
||
self.generateEngine() | ||
self.createSession() | ||
|
||
self.s3_bucket = os.environ['FILE_BUCKET'] | ||
self.createS3Client() | ||
|
||
def runProcess(self): | ||
try: | ||
|
||
response = airtable_integration.create_airtable_request() | ||
|
||
print(response) | ||
|
||
except Exception as e: | ||
logger.exception('Failed to run Pub Backlist process') | ||
raise e | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import os | ||
import requests | ||
|
||
def create_authorization_header(): | ||
bearer_token = os.environ.get("AIRTABLE_KEY") | ||
|
||
headers = {"Authorization": f"Bearer {bearer_token}"} | ||
|
||
return headers | ||
|
||
def create_airtable_request(): | ||
|
||
headers = create_authorization_header() | ||
|
||
response = requests.get('https://api.airtable.com/v0/appBoLf4lMofecGPU/Publisher%20Backlists%20%26%20Collections%20%F0%9F%93%96?view=UofMichigan%20Press&maxRecords=3', headers=headers) | ||
|
||
return response.json() |