-
Notifications
You must be signed in to change notification settings - Fork 12
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
AUTHORIZATION_URL and ACCESS_TOKEN_URL attributes usage #49
Conversation
Hi @Tatayoyoh, the issue is clear, but this was already suggested once in #31, and it wasn't merged because this solution causes issues to another backend. The thing I suggest is just to extend the class and override the URLs with appropriate values: from social_core.backends import facebook
class FacebookOAuth2(facebook.FacebookOAuth2):
AUTHORIZATION_URL = "https://www.facebook.com/v18.0/dialog/oauth"
ACCESS_TOKEN_URL = "https://graph.facebook.com/v18.0/oauth/access_token"
USER_DATA_URL = "https://graph.facebook.com/v18.0/me" |
Thanks for your fast answer :) So I just added a check condition if class OAuth2Core:
"""OAuth2 flow handler of a certain provider."""
...
def __init__(self, client: OAuth2Client) -> None:
...
self.backend = client.backend(OAuth2Strategy())
self._authorization_endpoint = self.backend.authorization_url() if hasattr(self.backend, 'authorization_url') else self.backend.AUTHORIZATION_URL
self._token_endpoint = self.backend.access_token_url() if hasattr(self.backend, 'access_token_url') else self.backend.ACCESS_TOKEN_URL It should do the job ! |
Hint: You can run |
…nd backend, which is malformed)
Yes thanks to the CI I have seen that too :) |
@Tatayoyoh, thanks for the effort you put into creating the PR. I have made little changes to yours so it will work with all the backends without skipping any of them :) https://docs.pysnippet.org/fastapi-oauth2/integration/configuration#backends |
Motivation:
Hi there !
When I'm using
FacebookOAuth2
orFacebookAppOAuth2
backends, and I'm facing to a wrong generated URL for OAuth like this :https://www.facebook.com/v{version}/dialog/oauth
Instead of
https://www.facebook.com/v18.0/dialog/oauth
After some investigations, the error provides from
OAuth2Strategy
incore.py
that defining an uncompleteget_setting()
code.I fixed it by getting settings through environment (for example, it fit with my Docker/FastAPI project :p)
One more fix is to use
authorization_url()
andaccess_token_url()
despite of to useAUTHORIZATION_URL
andACCESS_TOKEN_URL
that can contain variables likefacebook.py
backendHere is
facebook.py
from social_core package :Can you review this code and release a new version if it sounds good for you ?
Thanks a lot for your repo :)