-
-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Invalid backend parameter" for AzureAD Tenant #27
Comments
Hi @cheslijones. Thanks for creating the issue. Let's go by parts as there is a lot of information there. So backend should be what python-social-auth allows us to use, In my case I use The SOCIAL_AUTH_AZUREAD_OAUTH2_KEY = '' They must be retrieved from Azure. I myself never used Azure, but in order to authenticate with facebook I had to create a new facebook app. This new app provided me with a client key and client secret. Those must be set up in the settings.py. the |
Regarding your INSTALLED_APPS, you have the following:
Please, replace with the following:
Otherwise, the migrations will not properly! |
One more question, where did you see these values at the documentation: I could not see them. |
Thanks for the quick reply.
These two go together. I'm honestly guessing what it should be. I don't see it notated anywhere what exactly are acceptable values for this. Based on the two Integration examples:
So I figured for Azure it had to be one of the following:
Based on...
I was apparently wrong in this assumption. But the https://python-social-auth.readthedocs.io/en/latest/backends/azuread.html Is this value supposed to correspond with the app name for the app created in Django Admin, by chance?
SOCIAL_AUTH_AZUREAD_OAUTH2_KEY = '' They must be retrieved from Azure. I myself never used Azure, but in order to authenticate with facebook I had to create a new facebook app. This new app provided me with a client key and client secret. Those must be set up in the settings.py. Thanks for confirming. That is what it sounded like to me.
Thanks, I'll look into this in Azure. I reorganized my |
Well, I finally guessed the
I still need to sort out the |
I am happy that you managed to find the backend name. Look, what is the version of python-social-auth you're using? I have just visited this page: https://github.com/python-social-auth/social-core/blob/master/social_core/backends/azuread_tenant.py. This is the core from the file where your had the error. I can't find the same code in line 97! |
@cheslijones do you have any news about this? |
@wagnerdelima Hi, I actually had to throw in the towel on this and went with a client-side ReactJS solution for handling it. So far it has worked as expected. But to answer your question I was using 0.3.6 which I believe is the latest and it doesn't look like it has been updated in four years. |
I am sorry you had a bad experience. I think you were using a very old version. The latest version is 3.4.0 and the last commit is from Jun 21, 2020. That may be the reason! |
Ok, I'm back with hopefully a better understanding of how I need to implement this. My flow, as I understand it should be working between microservices, is the following:
Is this correct? If so, I have 1-3 working. Now I'm trying to send it to my API to also be validated for subsequent requests. This is where I'm struggling with the pretty much the same issues I had before. Here is what I have:
And I get the following error:
I have verified the request is URL params are formed correctly. Reluctant to post the Any suggestions as to what I'm doing wrong? |
Yes, it seems you have figured out what you have to do. So, let's try to change the order of your installed apps to:
Your DEFAULT_PERMISSION_CLASSES should also change (unrelated to your problem): Please try switching the order of things on the installed apps. I really don't think this is the cause of your troubles. I personally don't have a clue why you're getting this. Please let me know if you managed so we can plan a debug otherwise. |
Gave it a shot and still running into the same issue. I was playing with
I get a different error so I'm looking into that now:
|
Ok, I came across this looking at the RealmTeam/django-rest-framework-social-oauth2#42 I implemented the class here and added it to my At this point it is authenticating and retrieving user info, but creating users "weirdly" so I'll look into that tomorrow. I'll post what I end up doing to get this working. |
Hey @cheslijones can you please show me what are these weirdly looking users? |
@wagnerdelima Sorry, that was very unhelpful on my part. So it keeps creating a new user in the database even though it is the same user. There is probably a configuration I'm overlooking. I got this far pretty late in the day and I'm being pulled in a different direction for the rest of the week, so will probably be Monday before I can take a deeper look at this again. |
mm.. that's interesting. Integration Oauth2 with facebook generates users such as: NameSurname etc, instead of this unique id? Perhaps this is something from Azure itself? Did you manage to generate the token through the /convert-token endpoint though? |
@cheslijones do you have any news on this? |
Hi sorry, still working on another project for hopefully just another week and then I'll get back on this. |
@cheslijones any feedback here? |
@wagnerdelima Sorry, I've been on a whole bunch of other projects and hope to circle back to this in February. |
@wagnerdelima Hi, I have the same problem. I see users with id-like usernames in the database. The only difference is that I'm trying to authenticate using GitHub. On top of this problem, I run to IntegrityError:
Do you have any idea what can be causing this? |
Hi @MilanZiaran This is due to a user having the same email in the database. Then, once the user signs on with social OAuth, the integrity error is raised. This is something I will work on in the near future. |
@wagnerdelima Thank you very much for your quick response! Overriding the |
@MilanZiaran thank you for commenting. There might be an issue with the azure tenant from the social python. Not necessarily with drf-social-oauth2 framework. I will investigate this in the future for certain. I will leave this issue open. |
@wagnerdelima indeed, I've gone through that problem using Django Python Social Auth only. Seems to be linked with this issue => python-social-auth/social-core#70 |
I have been trying to implement Azure AD into my application, I get the access token from Microsoft however when I try to send the Error: Request payload:
I have tried backend: I have scanned as much of the internet and code as I can but I cannot seem to figure out a solution. Does anyone have any insight? Would it be possible to extend the max_length of the token CharField as identified as below?
I appreciate your time and response. Thank you. |
Just for clarity, the |
@wagnerdelima - Sorry to bother - I would very much appreciate your input here. I want to avoid creating a separate issues if possible as I believe the context to this issue is related to Azure specifically. I can kindly create a PR to increase the Thank you for your time and effort. EDIT: After further thought, I deem this a separate issue: #214 |
Been struggling to get this implemented and find the documentation pretty vague. I'd like to help improve it if I can get this working.
Related documentaiton:
https://python-social-auth.readthedocs.io/en/latest/backends/azuread.html
And then this is what I get when I try to run a POST request in Postman:
I've tried:
backend=azuread_tenant
backend=AzureADTenantOAuth2
backend=azureadtenantoauth2
Really isn't clear what the values of
backend
need to be, what are acceptable, where they can be found, or if it is an arbitrary designation.Also, in these
curl
requests:It seems like
<client_id>
and<client_secret>
are the values for the App in Django Admin, and not for the backend you are using (those are declared in thesettings.py
).There isn't a
convert_token
type for the App in Django Admin, so it is unclear what theAuthorization grant type
should be set at for the App in there.Also,
token=
isn't really discussed at all in the "Integration Examples", nor in thepython-social-auth
, oroauth2-provider
... so not sure if this is a value that is supposed to be generated by the backend provider when you are setting up the integration on their platform, or if it is something that is returned from the OAuth2 request and the/convert-token
is a second step...At any rate, the primary issue is the
invalid backend parameter
.The text was updated successfully, but these errors were encountered: