From 2225b223fc312e7c7e827631ca9823ee34b33638 Mon Sep 17 00:00:00 2001 From: Zsika Phillip Date: Tue, 17 Apr 2018 11:10:26 -0700 Subject: Adds documentation for parseIdToken (#1126) * Adds documentation for parseIdToken * Adds remarks to the documenation --- Firebase/Auth/Source/FIRUser.m | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'Firebase') diff --git a/Firebase/Auth/Source/FIRUser.m b/Firebase/Auth/Source/FIRUser.m index 0a0a664..013a13f 100644 --- a/Firebase/Auth/Source/FIRUser.m +++ b/Firebase/Auth/Source/FIRUser.m @@ -829,13 +829,26 @@ static void callInMainThreadWithAuthDataResultAndError( }); } +/** @fn parseIDToken:error: + @brief Parses the provided IDToken and returns an instance of FIRAuthTokenResult containing + claims obtained from the IDToken. + + @param token The raw text of the Firebase IDToken encoded in base64. + @param error An out parameter which would contain any error that occurs during parsing. + @return An instance of FIRAuthTokenResult containing claims obtained from the IDToken. + + @remarks IDToken returned from the backend in some cases is of a length that is not a multiple + of 4. In these cases this function pads the token with as many "=" characters as needed and + then attempts to parse the token. If the token cannot be parsed an error is returned via the + "error" out parameter. + */ - (FIRAuthTokenResult *)parseIDToken:(NSString *)token error:(NSError **)error { error = nil; NSArray *tokenStringArray = [token componentsSeparatedByString:@"."]; // The token payload is always the second index of the array. NSMutableString *tokenPayload = [[NSMutableString alloc] initWithString:tokenStringArray[1]]; - // Pad the token payload with "=" signs if the payload's length is not a multple of 4. + // Pad the token payload with "=" signs if the payload's length is not a multiple of 4. while ((tokenPayload.length % 4) != 0) { [tokenPayload appendFormat:@"="]; } -- cgit v1.2.3