inflearn logo
강의

Khóa học

Chia sẻ kiến thức

Bước đầu tiên để tự động hóa tác vụ: Gửi email hàng loạt và hoàn thành dự án thu thập thông tin bằng Python

Gửi thư bằng API Gmail

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

Đã giải quyết

352

dnehdgus5253306

2 câu hỏi đã được viết

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

Câu trả lời 1

1

hijuuny2858

안녕하세요 우동현님!

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

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

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

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

1

dnehdgus5253306

네 감사합니다.

실행되었습니다.^^

 

친절한 설명 감사합니다.

기출 11회 작업형 2_전체 데이터 학습 여부

0

15

1

RateLimitError

0

9

2

예측값 결과 소수점 차이

0

18

2

여태까지 발견한 이슈들 공유드립니다.

1

17

1

기출 문제와 실전챌린지 연습문제 무엇부터 푸는게 나은가요?

0

14

0

전처리 train() test([ ])

0

16

2

작업형 1 배경지식 질문

0

19

2

옳게 풀은건지 질문드립니다!

0

14

1

roc_auc_score

0

22

2

재귀함수 연산법

0

13

2

추가질문 합니다

0

16

2

시험환경 구름

0

18

2

2유형 질문드려요

0

15

2

RandomForest vs lgb

0

23

2

전처리 관련질문

0

23

3

수강기간즘연장해주세요

0

12

1

작업형3 기출

0

17

2

유형2에서 데이터분할 생략 가능여부

0

29

2

9회 기출 유형3 질문

0

19

2

lgb 기초편

0

14

1

수업자료 문의

0

18

2

괄호 사용

0

23

2

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

0

264

1

토큰 문제가 발생했어요

1

505

1