| 294 | } |
| 295 | |
| 296 | void OAuthService::AuthoriseCode( |
| 297 | const ServiceConfig& config, std::string_view authorizationCode, bool useAudioComRedirectURI, |
| 298 | AudiocomTrace trace, std::function<void(std::string_view)> completedHandler) |
| 299 | { |
| 300 | using namespace rapidjson; |
| 301 | |
| 302 | Document document; |
| 303 | document.SetObject(); |
| 304 | |
| 305 | WriteCommonFields(document, "authorization_code", "all"); |
| 306 | |
| 307 | document.AddMember( |
| 308 | "code", StringRef(authorizationCode.data(), authorizationCode.size()), |
| 309 | document.GetAllocator()); |
| 310 | |
| 311 | const auto redirectURI = useAudioComRedirectURI ? config.GetOAuthRedirectURL() : std::string("audacity://link"); |
| 312 | |
| 313 | document.AddMember( |
| 314 | "redirect_uri", StringRef(redirectURI.data(), redirectURI.size()), |
| 315 | document.GetAllocator()); |
| 316 | |
| 317 | rapidjson::StringBuffer buffer; |
| 318 | rapidjson::Writer<rapidjson::StringBuffer> writer(buffer); |
| 319 | document.Accept(writer); |
| 320 | |
| 321 | DoAuthorise( |
| 322 | config, { buffer.GetString(), buffer.GetSize() }, trace, |
| 323 | std::move(completedHandler), false); |
| 324 | } |
| 325 | |
| 326 | bool OAuthService::HasAccessToken() const |
| 327 | { |
nothing calls this directly
no test coverage detected