Skip to content

Commit cb4e790

Browse files
Merge pull request #210 from kapilraajP/config_revamp
Remove clientConfig from OAuth2RefreshTokenGrantConfig record
2 parents ef7511f + d5560dd commit cb4e790

File tree

2 files changed

+1
-120
lines changed

2 files changed

+1
-120
lines changed

gmail/config-types.bal

Lines changed: 0 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ public type OAuth2RefreshTokenGrantConfig record {|
7878
decimal clockSkew = 0;
7979
map<string> optionalParams?;
8080
CredentialBearer credentialBearer = AUTH_HEADER_BEARER;
81-
ClientConfiguration clientConfig = {};
8281
|};
8382

8483
# Represents the credential-bearing methods.
@@ -87,124 +86,6 @@ public enum CredentialBearer {
8786
POST_BODY_BEARER
8887
}
8988

90-
# Represents the configurations of the client used to call the introspection endpoint.
91-
#
92-
# + httpVersion - The HTTP version of the client
93-
# + customHeaders - The list of custom HTTP headers
94-
# + customPayload - The list of custom HTTP payload parameters
95-
# + auth - The client auth configurations
96-
# + secureSocket - SSL/TLS-related configurations
97-
public type ClientConfiguration record {|
98-
Oauth2HttpVersion httpVersion = HTTP_1_1;
99-
map<string> customHeaders?;
100-
string customPayload?;
101-
ClientAuth auth?;
102-
SecureSocket secureSocket?;
103-
|};
104-
105-
# Represents the HTTP versions.
106-
public enum Oauth2HttpVersion {
107-
HTTP_1_1,
108-
HTTP_2
109-
}
110-
111-
# Represents the the authentication configuration types for the HTTP client used for token introspection.
112-
public type ClientAuth ClientCredentialsGrantConfig|PasswordGrantConfig|RefreshTokenGrantConfig;
113-
114-
# Represents the data structure, which is used to configure the OAuth2 client credentials grant type.
115-
#
116-
# + tokenUrl - Token URL of the token endpoint
117-
# + clientId - Client ID of the client authentication
118-
# + clientSecret - Client secret of the client authentication
119-
# + scopes - Scope(s) of the access request
120-
# + defaultTokenExpTime - Expiration time (in seconds) of the tokens if the token endpoint response does not contain an `expires_in` field
121-
# + clockSkew - Clock skew (in seconds) that can be used to avoid token validation failures due to clock synchronization problems
122-
# + optionalParams - Map of the optional parameters used for the token endpoint
123-
# + credentialBearer - Bearer of the authentication credentials, which is sent to the token endpoint
124-
# + clientConfig - HTTP client configurations, which are used to call the token endpoint
125-
public type ClientCredentialsGrantConfig record {|
126-
string tokenUrl;
127-
string clientId;
128-
string clientSecret;
129-
string[] scopes?;
130-
decimal defaultTokenExpTime = 3600;
131-
decimal clockSkew = 0;
132-
map<string> optionalParams?;
133-
CredentialBearer credentialBearer = AUTH_HEADER_BEARER;
134-
ClientConfiguration clientConfig = {};
135-
|};
136-
137-
# Represents the data structure, which is used to configure the OAuth2 password grant type.
138-
#
139-
# + tokenUrl - Token URL of the token endpoint
140-
# + username - Username for the password grant type
141-
# + password - Password for the password grant type
142-
# + clientId - Client ID of the client authentication
143-
# + clientSecret - Client secret of the client authentication
144-
# + scopes - Scope(s) of the access request
145-
# + refreshConfig - Configurations for refreshing the access token
146-
# + defaultTokenExpTime - Expiration time (in seconds) of the tokens if the token endpoint response does not contain an `expires_in` field
147-
# + clockSkew - Clock skew (in seconds) that can be used to avoid token validation failures due to clock synchronization problems
148-
# + optionalParams - Map of the optional parameters used for the token endpoint
149-
# + credentialBearer - Bearer of the authentication credentials, which is sent to the token endpoint
150-
# + clientConfig - HTTP client configurations, which are used to call the token endpoint
151-
public type PasswordGrantConfig record {|
152-
string tokenUrl;
153-
string username;
154-
string password;
155-
string clientId?;
156-
string clientSecret?;
157-
string[] scopes?;
158-
record {|
159-
string refreshUrl;
160-
string[] scopes?;
161-
map<string> optionalParams?;
162-
CredentialBearer credentialBearer = AUTH_HEADER_BEARER;
163-
ClientConfiguration clientConfig = {};
164-
|} refreshConfig?;
165-
decimal defaultTokenExpTime = 3600;
166-
decimal clockSkew = 0;
167-
map<string> optionalParams?;
168-
CredentialBearer credentialBearer = AUTH_HEADER_BEARER;
169-
ClientConfiguration clientConfig = {};
170-
|};
171-
172-
# Represents the data structure, which is used to configure the OAuth2 refresh token grant type.
173-
#
174-
# + refreshUrl - Refresh token URL of the token endpoint
175-
# + refreshToken - Refresh token for the token endpoint
176-
# + clientId - Client ID of the client authentication
177-
# + clientSecret - Client secret of the client authentication
178-
# + scopes - Scope(s) of the access request
179-
# + defaultTokenExpTime - Expiration time (in seconds) of the tokens if the token endpoint response does not contain an `expires_in` field
180-
# + clockSkew - Clock skew (in seconds) that can be used to avoid token validation failures due to clock synchronization problems
181-
# + optionalParams - Map of the optional parameters used for the token endpoint
182-
# + credentialBearer - Bearer of the authentication credentials, which is sent to the token endpoint
183-
# + clientConfig - HTTP client configurations, which are used to call the token endpoint
184-
public type RefreshTokenGrantConfig record {|
185-
string refreshUrl;
186-
string refreshToken;
187-
string clientId;
188-
string clientSecret;
189-
string[] scopes?;
190-
decimal defaultTokenExpTime = 3600;
191-
decimal clockSkew = 0;
192-
map<string> optionalParams?;
193-
CredentialBearer credentialBearer = AUTH_HEADER_BEARER;
194-
ClientConfiguration clientConfig = {};
195-
|};
196-
197-
# Represents the SSL/TLS configurations.
198-
#
199-
# + disable - Disable SSL validation
200-
# + cert - Configurations associated with the `crypto:TrustStore` or single certificate file that the client trusts
201-
# + key - Configurations associated with the `crypto:KeyStore` or combination of certificate and private key of the client
202-
public type SecureSocket record {|
203-
boolean disable = false;
204-
TrustStore|string cert?;
205-
KeyStore|CertKey key?;
206-
|};
207-
20889
# Represents the truststore-related configurations.
20990
#
21091
# + path - Path to the TrustStore file

gmail/endpoint.bal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public isolated client class Client {
3232
# + return - An error on failure of initialization or else `()`
3333
public isolated function init(ConnectionConfig config) returns error? {
3434
http:ClientConfiguration httpClientConfig = {
35-
auth: config.auth,
35+
auth: let var authConfig = config.auth in (authConfig is BearerTokenConfig ? authConfig : {...authConfig}),
3636
httpVersion: config.httpVersion,
3737
http1Settings: {...config.http1Settings},
3838
http2Settings: config.http2Settings,

0 commit comments

Comments
 (0)