Skip to content
Open
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
15 changes: 15 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Upgrade Guide

## Upgrading from 5.x to 6.x

### Update typestate generic types on `Client`

The 6.x release includes breaking changes that make `Client` typestates specific to the type of endpoint being set.
This makes it possible to tell at a glance which endpoints are set for each instance of `Client`.

```rust
// v5.x syntax:
let client: BasicClient<EndpointSet, EndpointNotSet, EndpointNotSet, EndpointSet, EndpointSet> = todo!();

// v6.x syntax
let client: BasicClient<AuthEndpointSet, DeviceAuthEndpointNotSet, IntrospectionEndpointNotSet, RevocationEndpointSet, TokenEndpointSet> = todo!();
```

## Upgrading from 4.x to 5.x

The 5.0 release includes breaking changes to address several long-standing API issues, along with
Expand Down
21 changes: 12 additions & 9 deletions examples/wunderlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@ use oauth2::basic::{
BasicErrorResponse, BasicRevocationErrorResponse, BasicTokenIntrospectionResponse,
BasicTokenType,
};
use oauth2::reqwest;
use oauth2::StandardRevocableToken;
use oauth2::{
reqwest, AuthEndpointNotSet, IntrospectionEndpointNotSet, RevocationEndpointNotSet,
TokenEndpointNotSet,
};
use oauth2::{
AccessToken, AuthUrl, AuthorizationCode, Client, ClientId, ClientSecret, CsrfToken,
EmptyExtraTokenFields, EndpointNotSet, ExtraTokenFields, RedirectUrl, RefreshToken, Scope,
TokenResponse, TokenUrl,
EmptyExtraTokenFields, ExtraTokenFields, RedirectUrl, RefreshToken, Scope, TokenResponse,
TokenUrl,
};
use oauth2::{DeviceAuthEndpointNotSet, StandardRevocableToken};
use serde::{Deserialize, Serialize};
use url::Url;

Expand All @@ -35,11 +38,11 @@ use std::time::Duration;

type SpecialTokenResponse = NonStandardTokenResponse<EmptyExtraTokenFields>;
type SpecialClient<
HasAuthUrl = EndpointNotSet,
HasDeviceAuthUrl = EndpointNotSet,
HasIntrospectionUrl = EndpointNotSet,
HasRevocationUrl = EndpointNotSet,
HasTokenUrl = EndpointNotSet,
HasAuthUrl = AuthEndpointNotSet,
HasDeviceAuthUrl = DeviceAuthEndpointNotSet,
HasIntrospectionUrl = IntrospectionEndpointNotSet,
HasRevocationUrl = RevocationEndpointNotSet,
HasTokenUrl = TokenEndpointNotSet,
> = Client<
BasicErrorResponse,
SpecialTokenResponse,
Expand Down
18 changes: 11 additions & 7 deletions src/basic.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
use crate::{
client::{
AuthEndpointNotSet, DeviceAuthEndpointNotSet, IntrospectionEndpointNotSet,
RevocationEndpointNotSet, TokenEndpointNotSet,
},
revocation::{RevocationErrorResponseType, StandardRevocableToken},
Client, EmptyExtraTokenFields, EndpointNotSet, ErrorResponseType, RequestTokenError,
StandardErrorResponse, StandardTokenIntrospectionResponse, StandardTokenResponse, TokenType,
Client, EmptyExtraTokenFields, ErrorResponseType, RequestTokenError, StandardErrorResponse,
StandardTokenIntrospectionResponse, StandardTokenResponse, TokenType,
};

use std::fmt::Error as FormatterError;
use std::fmt::{Debug, Display, Formatter};

/// Basic OAuth2 client specialization, suitable for most applications.
pub type BasicClient<
HasAuthUrl = EndpointNotSet,
HasDeviceAuthUrl = EndpointNotSet,
HasIntrospectionUrl = EndpointNotSet,
HasRevocationUrl = EndpointNotSet,
HasTokenUrl = EndpointNotSet,
HasAuthUrl = AuthEndpointNotSet,
HasDeviceAuthUrl = DeviceAuthEndpointNotSet,
HasIntrospectionUrl = IntrospectionEndpointNotSet,
HasRevocationUrl = RevocationEndpointNotSet,
HasTokenUrl = TokenEndpointNotSet,
> = Client<
BasicErrorResponse,
BasicTokenResponse,
Expand Down
Loading