GIDAuthorizationUtil.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Copyright 2023 Google LLC
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import <Foundation/Foundation.h>
  17. @class OIDAuthorizationRequest;
  18. @class OIDAuthState;
  19. @class GIDSignInInternalOptions;
  20. @class OIDTokenRequest;
  21. NS_ASSUME_NONNULL_BEGIN
  22. /// The util class for authorization process.
  23. @interface GIDAuthorizationUtil : NSObject
  24. /// Creates the request to AppAuth to start the authorization flow.
  25. ///
  26. /// @param options The `GIDSignInInternalOptions` object to provide serverClientID, hostedDomain,
  27. /// clientID, scopes, loginHint and extraParams.
  28. /// @param emmSupport The EMM support info string.
  29. + (OIDAuthorizationRequest *)authorizationRequestWithOptions:(GIDSignInInternalOptions *)options
  30. emmSupport:(nullable NSString *)emmSupport;
  31. /// Creates the request to AppAuth to exchange auth code for access token.
  32. ///
  33. /// @param authState The current State of authorization session.
  34. /// @param serverClientID The server client ID.
  35. /// @param openIDRealm The open ID realm.
  36. /// @param emmSupport The EMM support string.
  37. + (OIDTokenRequest *)accessTokenRequestWithAuthState:(OIDAuthState *)authState
  38. serverClientID:(nullable NSString *)serverClientID
  39. openIDRealm:(nullable NSString *)openIDRealm
  40. emmSupport:(nullable NSString *)emmSupport;
  41. /// Unions granted scopes with new scopes or returns an error if the new scopes are the subset of
  42. /// the granted scopes.
  43. ///
  44. /// @param scopes The existing scopes.
  45. /// @param newScopes The new scopes to add.
  46. /// @param error The reference to the error.
  47. /// @return The array of all scopes or nil if there is an error.
  48. + (nullable NSArray<NSString *> *)
  49. resolvedScopesFromGrantedScopes:(NSArray<NSString *> *)scopes
  50. withNewScopes:(NSArray<NSString *> *)newScopes
  51. error:(NSError * __autoreleasing *)error;
  52. @end
  53. NS_ASSUME_NONNULL_END