From 2bd00a29745d3baaef75d918b48db045bcdc94d1 Mon Sep 17 00:00:00 2001 From: mdmathias Date: Fri, 8 Mar 2024 17:08:03 -0800 Subject: [PATCH] Fix OIDTokenRequest for AppAuthCore and AppAuthTV (#826) --- .../xcschemes/AppAuth-macOS.xcscheme | 22 ++++----- Source/AppAuthCore/OIDTokenRequest.h | 49 +++++++++++++++++++ Source/AppAuthCore/OIDTokenRequest.m | 46 +++++++++++++++++ Source/AppAuthTV/OIDTVTokenRequest.h | 14 ++++++ Source/AppAuthTV/OIDTVTokenRequest.m | 13 +++++ 5 files changed, 131 insertions(+), 13 deletions(-) diff --git a/AppAuth.xcodeproj/xcshareddata/xcschemes/AppAuth-macOS.xcscheme b/AppAuth.xcodeproj/xcshareddata/xcschemes/AppAuth-macOS.xcscheme index aa261aca6..74b33a822 100644 --- a/AppAuth.xcodeproj/xcshareddata/xcschemes/AppAuth-macOS.xcscheme +++ b/AppAuth.xcodeproj/xcshareddata/xcschemes/AppAuth-macOS.xcscheme @@ -27,6 +27,15 @@ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES"> + + + + @@ -39,17 +48,6 @@ - - - - - - - - *)scopes + refreshToken:(nullable NSString *)refreshToken + codeVerifier:(nullable NSString *)codeVerifier + additionalParameters:(nullable NSDictionary *)additionalParameters; + +/*! @param configuration The service's configuration. + @param grantType the type of token being sent to the token endpoint, i.e. "authorization_code" + for the authorization code exchange, or "refresh_token" for an access token refresh request. + @see OIDGrantTypes.h + @param code The authorization code received from the authorization server. + @param redirectURL The client's redirect URI. + @param clientID The client identifier. + @param clientSecret The client secret. + @param scope The value of the scope parameter is expressed as a list of space-delimited, + case-sensitive strings. + @param refreshToken The refresh token. + @param codeVerifier The PKCE code verifier. + @param additionalParameters The client's additional token request parameters. + */ +- (instancetype)initWithConfiguration:(OIDServiceConfiguration *)configuration + grantType:(NSString *)grantType + authorizationCode:(nullable NSString *)code + redirectURL:(nullable NSURL *)redirectURL + clientID:(NSString *)clientID + clientSecret:(nullable NSString *)clientSecret + scope:(nullable NSString *)scope + refreshToken:(nullable NSString *)refreshToken + codeVerifier:(nullable NSString *)codeVerifier + additionalParameters:(nullable NSDictionary *)additionalParameters; + /*! @param configuration The service's configuration. @param grantType the type of token being sent to the token endpoint, i.e. "authorization_code" for the authorization code exchange, or "refresh_token" for an access token refresh request. diff --git a/Source/AppAuthCore/OIDTokenRequest.m b/Source/AppAuthCore/OIDTokenRequest.m index e09e5577d..6d30b6d6b 100644 --- a/Source/AppAuthCore/OIDTokenRequest.m +++ b/Source/AppAuthCore/OIDTokenRequest.m @@ -89,6 +89,52 @@ - (instancetype)init additionalHeaders:) ) +- (instancetype)initWithConfiguration:(nonnull OIDServiceConfiguration *)configuration + grantType:(nonnull NSString *)grantType + authorizationCode:(nullable NSString *)code + redirectURL:(nullable NSURL *)redirectURL + clientID:(nonnull NSString *)clientID + clientSecret:(nullable NSString *)clientSecret + scopes:(nullable NSArray *)scopes + refreshToken:(nullable NSString *)refreshToken + codeVerifier:(nullable NSString *)codeVerifier + additionalParameters:(nullable NSDictionary *)additionalParameters { + return [self initWithConfiguration:configuration + grantType:grantType + authorizationCode:code + redirectURL:redirectURL + clientID:clientID + clientSecret:clientSecret + scopes:scopes + refreshToken:refreshToken + codeVerifier:codeVerifier + additionalParameters:additionalParameters + additionalHeaders:_additionalHeaders]; +} + +- (instancetype)initWithConfiguration:(nonnull OIDServiceConfiguration *)configuration + grantType:(nonnull NSString *)grantType + authorizationCode:(nullable NSString *)code + redirectURL:(nullable NSURL *)redirectURL + clientID:(nonnull NSString *)clientID + clientSecret:(nullable NSString *)clientSecret + scope:(nullable NSString *)scope + refreshToken:(nullable NSString *)refreshToken + codeVerifier:(nullable NSString *)codeVerifier + additionalParameters:(nullable NSDictionary *)additionalParameters { + return [self initWithConfiguration:configuration + grantType:grantType + authorizationCode:code + redirectURL:redirectURL + clientID:clientID + clientSecret:clientSecret + scope:scope + refreshToken:refreshToken + codeVerifier:codeVerifier + additionalParameters:additionalParameters + additionalHeaders:_additionalHeaders]; +} + - (instancetype)initWithConfiguration:(OIDServiceConfiguration *)configuration grantType:(NSString *)grantType authorizationCode:(nullable NSString *)code diff --git a/Source/AppAuthTV/OIDTVTokenRequest.h b/Source/AppAuthTV/OIDTVTokenRequest.h index 021dc9b9d..8643b4cc5 100644 --- a/Source/AppAuthTV/OIDTVTokenRequest.h +++ b/Source/AppAuthTV/OIDTVTokenRequest.h @@ -80,6 +80,20 @@ NS_ASSUME_NONNULL_BEGIN (nullable NSDictionary *)additionalHeaders NS_UNAVAILABLE; +/*! @brief Designated initializer. + @param configuration The service's configuration. + @param deviceCode The device verification code received from the authorization server. + @param clientID The client identifier. + @param clientSecret The client secret (nullable). + @param additionalParameters The client's additional token request parameters. +*/ +- (instancetype)initWithConfiguration:(OIDTVServiceConfiguration *)configuration + deviceCode:(NSString *)deviceCode + clientID:(NSString *)clientID + clientSecret:(nullable NSString *)clientSecret + additionalParameters: + (nullable NSDictionary *)additionalParameters; + /*! @brief Designated initializer. @param configuration The service's configuration. @param deviceCode The device verification code received from the authorization server. diff --git a/Source/AppAuthTV/OIDTVTokenRequest.m b/Source/AppAuthTV/OIDTVTokenRequest.m index ed5e4d3f2..0878c7934 100644 --- a/Source/AppAuthTV/OIDTVTokenRequest.m +++ b/Source/AppAuthTV/OIDTVTokenRequest.m @@ -90,6 +90,19 @@ - (instancetype)initWithConfiguration:(OIDServiceConfiguration *)configuration additionalHeaders: )) +- (instancetype)initWithConfiguration:(OIDTVServiceConfiguration *)configuration + deviceCode:(NSString *)deviceCode + clientID:(NSString *)clientID + clientSecret:(NSString *)clientSecret + additionalParameters:(NSDictionary *)additionalParameters { + return [self initWithConfiguration:configuration + deviceCode:deviceCode + clientID:clientID + clientSecret:clientSecret + additionalParameters:additionalParameters + additionalHeaders:nil]; +} + - (instancetype)initWithConfiguration:(OIDTVServiceConfiguration *)configuration deviceCode:(NSString *)deviceCode clientID:(NSString *)clientID