Skip to content
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

Missing description for method GraphAPI.exchange_user_access_token #238

Open
nbro10 opened this issue Sep 1, 2023 · 7 comments
Open

Missing description for method GraphAPI.exchange_user_access_token #238

nbro10 opened this issue Sep 1, 2023 · 7 comments
Labels
good first issue Good for newcomers

Comments

@nbro10
Copy link
Contributor

nbro10 commented Sep 1, 2023

Currently,

    def exchange_user_access_token(
        self,
        response: str,
        redirect_uri: Optional[str] = None,
        scope: Optional[List[str]] = None,
        **kwargs,
    ) -> dict:
        """
        :param response: The redirect response url for authorize redirect
        :param scope: A list of permission string to request from the person using your app.
        :param redirect_uri: Url for your redirect.
        :param kwargs: Additional parameters for oauth.
        :return:
        """

So, we have only a description of the parameters. This a public method, so it should have a description

@MerleLiuKun
Copy link
Member

Yes , you are right. We can add description for this, And other method.

@MerleLiuKun MerleLiuKun added the good first issue Good for newcomers label Sep 19, 2023
@nbro10
Copy link
Contributor Author

nbro10 commented Jan 31, 2024

@MerleLiuKun I think this method should also provide the possibility to generate the user access token given the authorization code or maybe there should be another method for that case.

Here, the response parameter is unclear to me. The docstrings says The redirect response url for authorize redirect, but this is a bit unclear to me. Where would we get this URL if usually what you get is an authorization code, when the user gives you permission? I suppose you would need to build this URL. Can you clarify what response is here?

@MerleLiuKun
Copy link
Member

the reponse is a url, it is generated by facebook.

When you generate a ouath url to let user operate. After user give permisson, Facebook will direct to the redirect url you have pointed at oauth url.

The direct url is the reponse

@nbro10
Copy link
Contributor Author

nbro10 commented Jan 31, 2024

@MerleLiuKun Alright, but isn't this URL just the redirect URI that you pass to api.get_authorization_url with the authorization code and the state? In that case, one can automatically build the this URL from what api.get_authorization_url returns. In my case, I actually get only the authorization code and the URL is in the browser, so I'd need to copy either the browser's URL or copy the authorization code and then build the URL. That's why I think this method should also accept the authorization code and state and be able to do the same job. Anyway, this parameter response should be renamed to something like redirect_url.

@MerleLiuKun
Copy link
Member

Yes you are right. But we think this is facebook's reponse. just style is a url

@kathanpatel0901
Copy link

but when we pass response url to exchange_user_access_token they gives encode error

response_url = request.build_absolute_uri()
    print("RESPONSE URL:", response_url)
    access_token = API.exchange_user_access_token(
        response=response_url, redirect_uri=FREDIRECT_URL
    )

error:'OAuth2Token' object has no attribute 'encode'

@MerleLiuKun
Copy link
Member

Could you give more information? I have not seen this error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants