diff options
author | Zsika Phillip <protocol86@users.noreply.github.com> | 2018-04-17 11:10:26 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-17 11:10:26 -0700 |
commit | 2225b223fc312e7c7e827631ca9823ee34b33638 (patch) | |
tree | 550a93f8c67574c0493c8fc05222a86d4bd7e8c5 /Firebase/Auth/Source/FIRUser.m | |
parent | 7f0b04afa2a058b9df6c00866bfe0a38f9640559 (diff) |
Adds documentation for parseIdToken (#1126)
* Adds documentation for parseIdToken
* Adds remarks to the documenation
Diffstat (limited to 'Firebase/Auth/Source/FIRUser.m')
-rw-r--r-- | Firebase/Auth/Source/FIRUser.m | 15 |
1 files changed, 14 insertions, 1 deletions
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:@"="]; } |