Skip to content

Added OAuth2 class, remaining API endpoints and some docs for contribution #159

Merged
johnwmillr merged 34 commits into
johnwmillr:masterfrom
allerter:complete_api
Sep 29, 2020
Merged

Added OAuth2 class, remaining API endpoints and some docs for contribution #159
johnwmillr merged 34 commits into
johnwmillr:masterfrom
allerter:complete_api

Conversation

@allerter
Copy link
Copy Markdown
Contributor

This PR completes the support of LyricsGenius of all the API endpoints available. I've also added the OAuth2 class with its docs, examples, and tests. I double if anyone will be using the endpoints that require a user access token, but it's nice to have them available just in case.
I also added some text to contributing.rst so that users who want to contribute can check the styling of their code before opening their PR.
I think it's also important to note that I renamed all instances of GENIUS_CLIENT_ACCESS_TOKEN TO GENIUS_ACCESS_TOKEN to avoid confusion since client access token is just one of the two kinds of tokens available: client access tokens and user tokens. The tests will also need a user token will all permissions token to be able to test the methods that are already implemented and the new ones that require a user access token with sufficient permission.

@allerter
Copy link
Copy Markdown
Contributor Author

@johnwmillr, this PR is ready to be merged.

Copy link
Copy Markdown
Owner

@johnwmillr johnwmillr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a comment about using OAuth properly in the unit tests. Are there extra steps to go through to get OAuth working with the tests?

Comment thread tests/test_genius.py
@allerter
Copy link
Copy Markdown
Contributor Author

The OAuth2 can't really be tested since it requires user input. But we could use a mock request just to test that it returns the correct result.

@allerter
Copy link
Copy Markdown
Contributor Author

I added the tests for the OAuth2 class and the utils functions. But now the tests require three more env vars: GENIUS_CLIENT_ID, GENIUS_CLIENT_SECRET, GENIUS_REDIRECT_URI.

Copy link
Copy Markdown
Owner

@johnwmillr johnwmillr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the tests for the OAuth2 class and the utils functions. But now the tests require three more env vars: GENIUS_CLIENT_ID, GENIUS_CLIENT_SECRET, GENIUS_REDIRECT_URI.

Excellent, thank you! I have your OAuth2 tests working locally now and will add the new environment vars for Travis-CI.

Comment thread lyricsgenius/api/base.py
if response.status_code == 200:
return response.json()['response']
res = response.json()
return res['response'] if "response" in res else res
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I often prefer using the get method directly when a key may not be present, but what you've written is fine.

return res.get("response", res)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return res.get("response", res) is actually better. Please replace it with that. Thanks.

Comment thread tests/test_auth.py
@johnwmillr johnwmillr merged commit e3bfe06 into johnwmillr:master Sep 29, 2020
@johnwmillr
Copy link
Copy Markdown
Owner

@allerter, I'm not sure why the commits from your PRs have been getting squashed, but I just now turned off the "Allow merge commits" option for this repository. Hopefully that resolves the issue.

@allerter allerter deleted the complete_api branch October 10, 2020 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants