python
from authomatic import Authomatic
from authomatic.providers import oauth2
CONFIG = {
'github': {
'class_': oauth2.GitHub,
'consumer_key': 'YOUR_GITHUB_CLIENT_ID',
'consumer_secret': 'YOUR_GITHUB_CLIENT_SECRET',
'access_headers': {'User-Agent': 'Authomatic'}
}
}
authomatic = Authomatic(CONFIG, 'your_secret_string')
response = authomatic.login(GitHub, request)
if response.successful():
access_token = response.access_token
user = response.user
else:
error = response.error
if user:
username = user.name
email = user.email