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

Oauth 1.0 usage instructions are unclear #181

Open
kwisatz opened this issue Oct 22, 2021 · 4 comments
Open

Oauth 1.0 usage instructions are unclear #181

kwisatz opened this issue Oct 22, 2021 · 4 comments

Comments

@kwisatz
Copy link
Contributor

kwisatz commented Oct 22, 2021

From the README's section on OAuth1:

The method continue_oauth() will either promt the user for a callback URL (normal bot runs) or it will take a parameter so in the case of WDI being used as a backend for e.g. a web app, where the callback will provide the authentication information directly to the backend and so no copy and paste of the callback URL is required.

Two things are unclear at this point when trying to use this authentication mechanism within a script/bot:

  1. When registering an oauth consumer, which value has to be inserted for OAuth "callback" URL?
  2. When the script prompts for a callback URL (Callback URL:), which value should be inserted

considering that a script does not have a webserver to call back to.

I also checked https://www.mediawiki.org/wiki/OAuth/For_Developers#OAuth_1.0a which didn't help all too much in finding answers to those questions.

@kwisatz
Copy link
Contributor Author

kwisatz commented Oct 22, 2021

I understood from reading the code that I can just paste any made-up callback URL given that all that we're interested in are the query arguments.
However, doing that, I got a TypeError: must be str or None, not bytes due to the use of split(b'?').
In my case, the question mark is not encoded and I had to remove the b prefix to make it work. Not sure in which case the pasted URL would be considered bytes instead of a string?

@kwisatz
Copy link
Contributor Author

kwisatz commented Oct 22, 2021

I stumbled upon https://www.mediawiki.org/wiki/Extension_talk:OAuthAuthentication#OAuth_%22callback%22_URL_for_OAuthAuthentication_applications just now. I haven't tried it yet though. Is that what would be recommended for WDI too?

@kwisatz
Copy link
Contributor Author

kwisatz commented Oct 7, 2022

I understood from reading the code that I can just paste any made-up callback URL given that all that we're interested in are the query arguments. However, doing that, I got a TypeError: must be str or None, not bytes due to the use of split(b'?'). In my case, the question mark is not encoded and I had to remove the b prefix to make it work. Not sure in which case the pasted URL would be considered bytes instead of a string?

This is still valid, and may be more pressing that the rest of this ticket.

kwisatz added a commit to tentwentyfour/WikidataIntegrator that referenced this issue Oct 7, 2022
The question mark that is part of the oauth callback URL is not
byte-encoded.
Keeping the byte-encoding mark in here leads to

```
    response_qs = self.response_qs.split(b'?')[-1]
TypeError: must be str or None, not bytes
```

This may differ per platform, but then maybe this PR will
spark a discussion that has not yet been started from issue SuLab#181
@andrawaag
Copy link
Collaborator

Thank you for your pull request. I am restructuring the repo a bit to get a better grip on the library. Unfortunately, I am not an expert on OAUTH. Since raising the issue have you gained a better understanding? If so can I ask for another pull request?

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

No branches or pull requests

2 participants