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

Add custom auth URLs and simplify get/etc methods #356

Merged
merged 4 commits into from
Jan 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 0.11.7 (Unreleased)

- ([#375](https://github.com/ramsayleung/rspotify/pull/375)) We now use `chrono::Duration` in more places for consistency and usability: `start_uris_playback`, `start_context_playback`, `rspotify_model::Offset`, `resume_playback`, `seek_track`. Some of these fields have been renamed from `position_ms` to `position`.
- ((#356)[https://github.com/ramsayleung/rspotify/pull/356]) We now support custom authentication base URLs. `Config::prefix` has been renamed to `Config::api_base_url`, and we've introduced `Config::auth_base_url`.

## 0.11.6 (2022.12.14)

Expand Down
5 changes: 3 additions & 2 deletions doc/uml/trait_hierarchy.plantuml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ abstract class BaseClient {
---
ClientResult<()> auto_reauth()
ClientResult<()> refresh_token()
String endpoint_url()
String api_url()
String auth_url()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@ramsayleung, can you generate the diagram again? Do you know if there's a way to do this automatically instead?

Copy link
Owner

Choose a reason for hiding this comment

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

Yes, I can regenerate this diagram, but generating the diagram manually is a little clumsy, I would like to figure out how to generate this diagram automatically.

Copy link
Owner

Choose a reason for hiding this comment

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

I think we could use this GitHub Action to generate an image from plantuml file automatically: https://github.com/marketplace/actions/generate-plantuml

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Great! Then you can ignore this comment, and we'll set it up in a separate PR.

ClientResult<Headers> auth_headers()
ClientResult<()> write_token_cache()
ClientResult<Token> fetch_access_token()
Expand Down Expand Up @@ -55,4 +56,4 @@ class ClientCredsSpotify implements BaseClient{
ClientResult<Option<Token>> refetch_token()
---
}
@enduml
@enduml
3 changes: 2 additions & 1 deletion src/auth_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ impl AuthCodeSpotify {
payload.insert(params::SHOW_DIALOG, "true");
}

let parsed = Url::parse_with_params(auth_urls::AUTHORIZE, payload)?;
let request_url = self.auth_url(auth_urls::AUTHORIZE);
let parsed = Url::parse_with_params(&request_url, payload)?;
Ok(parsed.into())
}
}
3 changes: 2 additions & 1 deletion src/auth_code_pkce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ impl AuthCodePkceSpotify {
payload.insert(params::STATE, &self.oauth.state);
payload.insert(params::SCOPE, &scopes);

let parsed = Url::parse_with_params(auth_urls::AUTHORIZE, payload)?;
let request_url = self.auth_url(auth_urls::AUTHORIZE);
let parsed = Url::parse_with_params(&request_url, payload)?;
Ok(parsed.into())
}
}
Loading