I have added scopes to each provider but I do not receive all the additional data in extra_data. I only receive the default extra data. When using oauth facebook does ask to I will allow the data to be used but I do not recieve the data such as user_likes, user_activites. Same with google, and instagram. The spotify provider is a custom provider.
SOCIALACCOUNT_PROVIDERS = \
{
'facebook':
{'SCOPE': ['email', 'public_profile', 'user_activities', 'user_likes',
'user_interests', 'publish_stream', 'user_friends'],
'AUTH_PARAMS': {'auth_type': 'reauthenticate'},
'METHOD': 'js_sdk'},
'google':
{'SCOPE': ['https://www.googleapis.com/auth/userinfo.profile', 'https://www.googleapis.com/auth/userinfo.email',
'https://www.googleapis.com/auth/youtube.readonly']
, 'AUTH_PARAMS': {}},
'instagram':
{'SCOPE': ['basic']
, 'AUTH_PARAMS': {}},
'spotify':
{'SCOPE': ['playlist-modify-public', 'user-follow-read', 'user-read-email']
, 'AUTH_PARAMS': {}},
}
This is probably a bit too late, but I had the same problem fetching additional data from Facebook using django-allauth.
The solution was to simply list the fields you want.
SOCIALACCOUNT_PROVIDERS = \
{
'facebook':
{'SCOPE': ['email', 'public_profile', 'user_activities', 'user_likes','user_interests', 'publish_stream', 'user_friends'],
'AUTH_PARAMS': {'auth_type': 'reauthenticate'},
'METHOD': 'js_sdk',
'FIELDS': [
'id',
'email',
'name',
'first_name',
'last_name',
'likes', #This is the one you want
'friends',
# user_interests is deprecated
],},
# other providers
}
The same probably applies to all the others too. I cannot say as I haven't used any others yet.
Related
I want to put this response in swagger doc too! I use drf_yasg app in django. I've written this code:
#swagger_auto_schema(method='post', request_body=openapi.Schema(
type=openapi.TYPE_OBJECT,
properties={
'login_id': openapi.Schema(type=openapi.TYPE_STRING, description='ID'),
'password': openapi.Schema(type=openapi.TYPE_STRING, description='password'),
}
))
The current swagger_auto_schema property is
{
"login_id": "admin",
"password": "1234",
}
I want to make swagger_auto_schema in the format below
{
"User": {
"login_id": "admin",
"password": "1234",
}
}
I don't know how to provide json data
You need to define the "User" wrapper explicitly in your schema:
#swagger_auto_schema(method='post', request_body=openapi.Schema(
type=openapi.TYPE_OBJECT,
properties={
'User': openapi.Schema(
type=openapi.TYPE_OBJECT,
properties={
'login_id': openapi.Schema(type=openapi.TYPE_STRING, description='ID'),
'password': openapi.Schema(type=openapi.TYPE_STRING, description='password'),
}
)
}
))
I am using Django all-auth to enable Google & Facebook social logins to my application. The flow is working fine but there are two unnecessary screens in the flow. The config is as follows:
ACCOUNT_ALLOW_REGISTRATION = env.bool("DJANGO_ACCOUNT_ALLOW_REGISTRATION", True)
ACCOUNT_AUTHENTICATION_METHOD = "email"
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_USERNAME_REQUIRED = False
ACCOUNT_EMAIL_VERIFICATION = "none"
ACCOUNT_ADAPTER = "project.users.adapters.AccountAdapter"
SOCIALACCOUNT_ADAPTER = "project.users.adapters.SocialAccountAdapter"
SOCIALACCOUNT_PROVIDERS = {
"google": {
"SCOPE": [
"profile",
"email",
"https://www.googleapis.com/auth/youtube",
"https://www.googleapis.com/auth/youtube.readonly",
"https://www.googleapis.com/auth/youtube.upload",
"https://www.googleapis.com/auth/youtube.force-ssl",
],
"AUTH_PARAMS": {
"access_type": "offline",
},
},
"facebook":
{
'METHOD': 'oauth2',
'SCOPE': ['email', 'public_profile'],
'AUTH_PARAMS': {'auth_type': 'reauthenticate'},
'INIT_PARAMS': {'cookie': True},
'FIELDS': [
'id',
'first_name',
'last_name',
'middle_name',
'name',
'name_format',
'picture',
'short_name'
],
'EXCHANGE_TOKEN': True,
'LOCALE_FUNC': lambda request: 'en_US',
'VERIFIED_EMAIL': False,
'VERSION': 'v7.0',
},
}
This is what I see after clicking on Google/Facebook login button:
And this comes up after completing Facebook login:
I don't want any of these two intermediate screens, and tried modifying configuration as well. But these screens are not mentioned in the Django All-Auth docs so what am I missing?
The docs don't recommend using SOCIALACCOUNT_LOGIN_ON_GET = True for security reasons. Use a form instead to send a POST request:
<form action="{% provider_login_url 'facebook' %}" method="post">
{% csrf_token %}
<button type="submit">Continue with Facebook</button>
</form>
You also need to set SOCIALACCOUNT_AUTO_SIGNUP = True in settings.py (this is the default value).
Try setting SOCIALACCOUNT_LOGIN_ON_GET to TRUE.
https://django-allauth.readthedocs.io/en/latest/release-notes.html#backwards-incompatible-changes-1
Open your setting.py file of django project
and add following line in bottom of the file
SOCIALACCOUNT_LOGIN_ON_GET = True
I use python social auth and django rest framework.
I want to fetch the user phone number.
Settings
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = config('GOOGLE_ID')
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = config('GOOGLE_SECRET')
SOCIAL_AUTH_RAISE_EXCEPTIONS = False
SOCIAL_AUTH_USER_MODEL = 'users.TransUser'
SOCIAL_AUTH_GOOGLE_OAUTH2_USER_FIELDS = ['email', 'firstname', 'lastname', 'phone_number']
SOCIAL_AUTH_GOOGLE_OAUTH2_SCOPE = [
'https://www.googleapis.com/auth/userinfo.email',
'https://www.googleapis.com/auth/userinfo.profile',
'https://www.googleapis.com/auth/user.phonenumbers.read',
'profile',
'email',
]
Ouput
{'access_token': 'xxxxxxxx',
'email': 'xxxxxxxx,
'email_verified': True,
'expires_in': 3582,
'family_name': 'xxxxxxx',
'given_name': 'xxxxx',
'id_token': 'xxxxxx',
'locale': 'es',
'name': 'xxxxxxx',
'picture': 'xxxxx',
'scope': 'https://www.googleapis.com/auth/userinfo.email '
'https://www.googleapis.com/auth/user.phonenumbers.read '
'https://www.googleapis.com/auth/userinfo.profile openid',
'sub': 'xxxxxx',
'token_type': 'Bearer'}
but never phone number.
I use user's phone number to registration it.
I activated people APi in google console.
Thx you
I'd like to get the user email from the twitter oauth. So I requested this in the app settings.
I added the scope (to settings.py):
SOCIALACCOUNT_PROVIDERS = {
'linkedin': {
'SCOPE': [
'r_emailaddress',
'r_basicprofile',
'r_fullprofile',
],
'PROFILE_FIELDS': [
'id',
'first-name',
'last-name',
'positions',
'email-address',
'picture-url',
'public-profile-url',
'headline',
'skills',
'summary',
'location',
'industry',
'positions',
'company',
'specialties',
'public-profile-url',
],
'LOCATION_FIELDS': [
'location',
],
'POSITION_FIELDS': [
'company',
]
},
'twitter': {
'SCOPE': ['email'],
},
}
However, I'm still having the user data like the name, picture ..etc but not the email.
Any suggestion ?
I'm trying to create new project sheets in a folder, however I can't find a way to ensure the sheet is a project sheet.
Here is my code so far:
def create_resource_sheet(name):
""" Create a new resource sheet.
:param name:
:return:
"""
folder_id = get_resource_folder_id()
# TODO: Find and delete existing sheet with this name
resource_sheet = SS.models.Sheet({
'name': name,
# 'gantt_enabled': True, # This was added as an attempt to force it to a project sheet, but error 1032
'columns': [{
'title': 'Task',
'type': 'TEXT_NUMBER',
'primary': True,
'width': 200
}, {
'title': 'Status',
'type': 'PICKLIST',
'options': ['wtg', 'hld', 'ip', 'rdy', 'rev', 'fin', 'omt'], # TODO: Update this list
'width': 180
}, {
'title': '% Complete',
'type': 'TEXT_NUMBER',
'tag': ['GANTT_PERCENT_COMPLETE'],
'width': 85
}, {
'title': 'Assigned To',
'type': 'CONTACT_LIST',
'tag': ['GANTT_ASSIGNED_RESOURCE', 'GANTT_DISPLAY_LABEL'],
'width': 150
}, {
'title': '% Use',
'type': 'TEXT_NUMBER',
'tag': ['GANTT_ALLOCATION'],
'width': 60
}, {
'title': 'Days',
'type': 'DURATION',
'tag': ['GANTT_DURATION'],
'width': 70
}, {
'title': 'Start',
'type': 'ABSTRACT_DATETIME',
'tag': ['CALENDAR_START_DATE', 'GANTT_START_DATE'],
'width': 80
}, {
'title': 'Start',
'type': 'ABSTRACT_DATETIME',
'tag': ['CALENDAR_START_DATE', 'GANTT_START_DATE'],
'width': 80
}, {
'title': 'Finish',
'type': 'ABSTRACT_DATETIME',
'tag': ['CALENDAR_END_DATE', 'GANTT_END_DATE'],
'width': 80
}, {
'title': 'Type',
'type': 'TEXT_NUMBER',
'width': 150
}, {
'title': 'Comments',
'type': 'TEXT_NUMBER',
'width': 700
}
]
})
response = SS.Folders.create_sheet_in_folder(folder_id, resource_sheet)
new_sheet = response.result
return new_sheet
I am getting the following error code:
smartsheet.exceptions.ApiError: {"result": {"shouldRetry": false,
"code": 1142, "name": "ApiError", "errorCode": 1142, "recommendation":
"Do not retry without fixing the problem. ", "message": "Column type
DURATION is reserved for project sheets and may not be manually set on
a column.", "refId": "6gurrzzwhepe", "statusCode": 400}}
Is there a way I can create project sheets from scratch?
I have tried setting gantt_enabled to true but that just triggered a different error, so did setting 'project_settings'.
I have tried creating the sheet with just the primary column, then update_sheet to set project settings, which tells me: To set projectSettings, you must first enable dependencies on the sheet.
I have tried setting dependencies enabled, both directly in the create_sheet and in update_sheet, but both return: The attribute(s) sheet.dependenciesEnabled are not allowed for this operation.
I'm going to keep trying things, but I'm getting out of ideas.
Create the sheet from a template, either using the global project template or a user defined template if you want to customize.
templates = SS.Templates.list_public_templates()
for template in templates.data:
if template.global_template ==
smartsheet.models.enums.GlobalTemplate.PROJECT_SHEET:
break
sheet = smartsheet.models.Sheet({
'name': name,
'from_id': template.id
})
resource_sheet = SS.Folders.create_sheet_in_folder(folder_id, sheet)
If you want to customize create a project sheet using the Smartsheet web UI, make your changes and then Save As Template. Once you have the template, grab the ID from the Properties if you don't want to search for it, or SS.Templates.list_user_created_templates().
You cannot create a new dependency-enabled sheet through the API. You'll need to manually create a template and then use the API to make a copy.