๋ฐ์ํ
serviceName='oauth2', version='v2'
์๋น์ค๋ช , ๋ฒ์ ๋ญ๋ก ํด์ผํ ์ง ๋ชฐ๋ผ์ email ์ ๋ณด ์ป๊ธฐ ํ์ฐธ ํค๋งด ใ ใ
์๋น์ค๋ช ์ ๋ณด ์๋ ๊ณณ ์์๋ ๋ถ ์๋ ค์ฃผ์ธ์ง!
import googleapiclient.discovery
def get_user_info(credentials):
"""Send a request to the UserInfo API to retrieve the user's information.
Args:
credentials: oauth2client.client.OAuth2Credentials instance to authorize the
request.
Returns:
User information as a dict.
"""
user_info_service = googleapiclient.discovery.build('oauth2', 'v2', credentials=credentials)
return user_info_service.userinfo().get().execute()
# try:
# user_info = user_info_service.userinfo().get().execute()
# except errors.HttpError, e:
# logging.error('An error occurred: %s', e)
# if user_info and user_info.get('id'):
# return user_info
# else:
# raise NoUserIdException()
user_email = get_user_info(credentials)['email']
stackoverflow.com/questions/19473250/how-to-get-user-email-after-oauth-with-google-api-python-client
๋ฐ์ํ
'Python > Basic' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Python] ์์ธ ๋ฐ์ ์ํค๊ธฐ, ๋ฉ์ธ์ง ์ถ๋ ฅ (0) | 2020.10.22 |
---|---|
[Python] cx_Oracle ํ๊ธ ๊นจ์ง (0) | 2020.10.20 |
[Python] python-docx - word ์ฝ๊ธฐ/ํธ์ง ํ๊ธฐ (0) | 2020.08.14 |
[Python] openpyxl - ์์ ์ฝ๊ธฐ/ํธ์ง ํ๊ธฐ (0) | 2020.08.14 |
Streamlit. The fastest way to build custom ML tools (0) | 2020.03.25 |