inflearn logo
강의

Course

Instructor

First Steps in Task Automation: Sending Bulk Emails and Completing a Crawling Project with Python

Sending mail using Gmail API

샘플 코드가 다른거 같아요.

Resolved

384

dnehdgus5253306

2 asked

1

안녕하세요, 수강생 여러분

  1. 학습 관련 내용을 질문해주세요!

     

영상에나온 Gmail Api python 샘플 코드와 현재 구글에서 제공하는 샘플 코드가 다른거같아요.

영상에서 나온 코드를 직접 타이핑 하면될까요?

참고로 구글에서 제공하는 샘플코드는 아래와 같아요.

import os.path

from google.auth.transport.requests import Request
from google.oauth2.credentials import Credentials
from google_auth_oauthlib.flow import InstalledAppFlow
from googleapiclient.discovery import build
from googleapiclient.errors import HttpError

# If modifying these scopes, delete the file token.json.
SCOPES = ["https://www.googleapis.com/auth/gmail.readonly"]


def main():
  """Shows basic usage of the Gmail API.
  Lists the user's Gmail labels.
  """
  creds = None
  # The file token.json stores the user's access and refresh tokens, and is
  # created automatically when the authorization flow completes for the first
  # time.
  if os.path.exists("token.json"):
    creds = Credentials.from_authorized_user_file("token.json", SCOPES)
  # If there are no (valid) credentials available, let the user log in.
  if not creds or not creds.valid:
    if creds and creds.expired and creds.refresh_token:
      creds.refresh(Request())
    else:
      flow = InstalledAppFlow.from_client_secrets_file(
          "credentials.json", SCOPES
      )
      creds = flow.run_local_server(port=0)
    # Save the credentials for the next run
    with open("token.json", "w") as token:
      token.write(creds.to_json())

 

 

  1. 개인적으로 스크래핑/크롤링하는 사이트에 대한 질문에 대해서는 답변을 드리지 않아요!

python slack beautifulsoup github-actions gmail-api

Answer 1

1

hijuuny2858

안녕하세요 우동현님!

먼저 강의에 나온코드는 구글 샘플 코드를 참조한 코드이며, 약간 변형이 있습니다.

강의에 나온것을 사용하시면 되며, 복사를 원하시는 경우 아래 깃허브 주소에서 가져가시면 됩니다!

https://github.com/heohyunjun/Inflearn-road-to-business-automation

감사합니다, 추가 질문있으신 경우 언제든 남겨주세요!

1

dnehdgus5253306

네 감사합니다.

실행되었습니다.^^

 

친절한 설명 감사합니다.

수강 연장가능여부 문의드립니다!

0

5

1

수강기간 연장 문의드립니다!

0

16

1

최빈값

0

13

2

수강 가이드라인

0

15

2

교재 문의

0

24

2

수강 연장 가능 여부 문의

0

35

2

강의 구매했는데 교재 필수일까요

0

24

2

수강기간 연장 가부 문의드립니다.

0

24

2

수강기간 연장이 가능한지 양해를 구하며 문의를 드립니다.

0

28

2

정처기 2026-3 실기 문의

0

59

2

정처기 실기 3회 컴싸 사용 여부

0

34

1

매수하기

0

32

2

작업형2 모의문제2에서 drop이랑 인코딩

0

34

2

모의고사 1 회 2번문제 중

0

52

2

26-2 이론문제 재탕

1

40

1

26-2년도 코드문제

0

29

0

26-2 코드문제

0

31

1

15분 48초 질문

0

42

2

26-1년도 이론문제 재탕

0

58

1

26-1년도 코드문제 재탕

0

42

0

계좌잔고 조회하기

0

37

1

안녕하세요 강사님

0

37

1

vs code와 github연결 방법을 모르겠어요

0

320

1

토큰 문제가 발생했어요

1

542

1