Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to obtain a JWT token (id_token)? #28

Closed
shankari opened this issue Apr 18, 2017 · 3 comments
Closed

how to obtain a JWT token (id_token)? #28

shankari opened this issue Apr 18, 2017 · 3 comments
Labels

Comments

@shankari
Copy link

In the previous version of the library (gtm-oauth2), there was a way to obtain the JWT token from an authorization object using the id_token parameter. I use JWTs for cross-device authentication, so I want to get access to the token and authenticate my requests myself.

    // else, the real version
    if (self.currAuth != NULL) {
        if (self.currAuth.canAuthorize) {
            return [self.currAuth.parameters valueForKey:@"id_token"];
        }
    }

I don't see a way to do that with this replacement library. In particular, I don't see a parameters property for the GTMAppAuthFetcherAuthorization, and I don't see the source code for the OIDAuthState object, which is where the rest of the tokens appear to live.

@shankari
Copy link
Author

shankari commented Apr 18, 2017

to add to my own question, and to add to #3, it looks like there is a way to get the id token using the Google+ sign in library. Is the user.authentication object below an GTMAppAuthFetcherAuthorization object, and if so, can we get a token from it?

- (void)signIn:(GIDSignIn *)signIn
didSignInForUser:(GIDGoogleUser *)user
     withError:(NSError *)error {
  // Perform any operations on signed in user here.
  NSString *userId = user.userID;                  // For client-side use only!
  NSString *idToken = user.authentication.idToken; // Safe to send to the server
  NSString *fullName = user.profile.name;
  NSString *givenName = user.profile.givenName;
  NSString *familyName = user.profile.familyName;
  NSString *email = user.profile.email;
  // ...
}

@shankari
Copy link
Author

and to answer my own question, it is an GIDAuthentication instead.
I am going to wait a bit to see if there is an answer to this question but otherwise, I might just switch to the google identity sign in libraries instead.
https://developers.google.com/identity/sign-in/ios/api/interface_g_i_d_google_user

@zboralski
Copy link

@StevenEWright GTMAppAuthFetcherAuthorization.authState.lastTokenResponse.idToken

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants