FIRStorageTokenAuthorizer.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. @class FIRApp;
  18. NS_ASSUME_NONNULL_BEGIN
  19. /**
  20. * Wrapper class for FIRApp 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 app An instance of FIRApp which provides auth tokens.
  30. * @return Returns an instance of FIRStorageTokenAuthorizer which adds the appropriate
  31. * "Authorization" header to all outbound requests. Note that a token may not be added
  32. * if a getTokenImplementation doesn't exist on FIRApp. This allows for unauthenticated
  33. * access, if Firebase Storage rules allow for it.
  34. */
  35. - (instancetype)initWithApp:(FIRApp *)app fetcherService:(GTMSessionFetcherService *)service;
  36. @end
  37. NS_ASSUME_NONNULL_END