FIRUser_Internal.h 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 "FIRUser.h"
  17. @class FIRAuth;
  18. NS_ASSUME_NONNULL_BEGIN
  19. /** @typedef FIRRetrieveUserCallback
  20. @brief The type of block that is invoked when the construction of a user succeeds or fails.
  21. @param user The user that was constructed, or nil if user construction failed.
  22. @param error The error which occurred, or nil if the request was successful.
  23. */
  24. typedef void(^FIRRetrieveUserCallback)(FIRUser *_Nullable user, NSError *_Nullable error);
  25. @interface FIRUser () <NSSecureCoding>
  26. /** @property rawAccessToken
  27. @brief The cached access token.
  28. @remarks This method is specifically for providing the access token to internal clients during
  29. deserialization and sign-in events, and should not be used to retrieve the access token by
  30. anyone else.
  31. */
  32. @property(nonatomic, copy, readonly) NSString *rawAccessToken;
  33. /** @property auth
  34. @brief A weak reference to a FIRAuth instance associated with this instance.
  35. */
  36. @property(nonatomic, weak) FIRAuth *auth;
  37. /** @var accessTokenExpirationDate
  38. @brief The expiration date of the cached access token.
  39. */
  40. @property(nonatomic, copy, readonly) NSDate *accessTokenExpirationDate;
  41. /** @fn retrieveUserWithAuth:accessToken:accessTokenExpirationDate:refreshToken:callback:
  42. @brief Constructs a user with Secure Token Service tokens, and obtains user details from the
  43. getAccountInfo endpoint.
  44. @param auth The associated FIRAuth instance.
  45. @param accessToken The Secure Token Service access token.
  46. @param accessTokenExpirationDate The approximate expiration date of the access token.
  47. @param refreshToken The Secure Token Service refresh token.
  48. @param anonymous Whether or not the user is anonymous.
  49. @param callback A block which is invoked when the construction succeeds or fails. Invoked
  50. asynchronously on the auth global work queue in the future.
  51. */
  52. + (void)retrieveUserWithAuth:(FIRAuth *)auth
  53. accessToken:(NSString *)accessToken
  54. accessTokenExpirationDate:(NSDate *)accessTokenExpirationDate
  55. refreshToken:(NSString *)refreshToken
  56. anonymous:(BOOL)anonymous
  57. callback:(FIRRetrieveUserCallback)callback;
  58. /** @fn internalGetTokenForcingRefresh:callback:
  59. @brief Retrieves the Firebase authentication token, possibly refreshing it if it has expired.
  60. @param forceRefresh Forces a token refresh. Useful if the token becomes invalid for some reason
  61. other than an expiration.
  62. @param callback The block to invoke when the token is available. Invoked asynchronously on the
  63. global work thread in the future.
  64. */
  65. - (void)internalGetTokenForcingRefresh:(BOOL)forceRefresh
  66. callback:(nonnull FIRAuthTokenCallback)callback;
  67. @end
  68. NS_ASSUME_NONNULL_END