FIRStorageTokenAuthorizer.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Copyright 2017 Google
  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 <GTMSessionFetcher/GTMSessionFetcherService.h>
  17. @protocol FIRAuthInterop;
  18. NS_ASSUME_NONNULL_BEGIN
  19. /**
  20. * Wrapper class for FIRAuthInterop that implements the GTMFetcherAuthorizationProtocol,
  21. * so as to easily provide GTMSessionFetcher fetches a Firebase Authentication JWT
  22. * for the current logged in user. Handles token expiration and other failure cases.
  23. * If no authentication provider exists or no token is found, no token is added
  24. * and the request is passed.
  25. */
  26. @interface FIRStorageTokenAuthorizer : NSObject <GTMFetcherAuthorizationProtocol>
  27. /**
  28. * Initializes the token authorizer with an instance of FIRApp.
  29. * @param googleAppID The Google AppID of the app to send with the request.
  30. * @param auth An instance that provides access to Auth functionality, if it exists.
  31. * @return Returns an instance of FIRStorageTokenAuthorizer which adds the appropriate
  32. * "Authorization" header to all outbound requests. Note that a token may not be added
  33. * if the Auth instance is nil. This allows for unauthenticated access, if Firebase
  34. * Storage rules allow for it.
  35. */
  36. - (instancetype)initWithGoogleAppID:(NSString *)googleAppID
  37. fetcherService:(GTMSessionFetcherService *)service
  38. authProvider:(nullable id<FIRAuthInterop>)auth;
  39. @end
  40. NS_ASSUME_NONNULL_END