Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

32
LINES

< > BotCompany Repo | #1013821 // googleVerifyUserToken2

JavaX fragment (include) [tags: use-pretranspiled]

Uses 1658K of libraries. Click here for Pure Java version (2499L/16K).

lib 1013814 // google http client
lib 1013815 // google api client
lib 1013816 // google oauth client
lib 1013817 // jackson
lib 1013818 // google jackson2
lib 1013819 // google http client appengine

import com.google.api.client.googleapis.auth.oauth2.GoogleIdToken;
import com.google.api.client.googleapis.auth.oauth2.GoogleIdToken.Payload;
import com.google.api.client.googleapis.auth.oauth2.GoogleIdTokenVerifier;
import com.google.api.client.json.jackson2.JacksonFactory;
import com.google.api.client.http.javanet.NetHttpTransport;

static Payload googleVerifyUserToken2(S clientID, S token) ctex {
  print("Google verify started.");
  
  new NetHttpTransport transport;
  
  GoogleIdTokenVerifier verifier = new GoogleIdTokenVerifier.Builder(transport, new JacksonFactory)
    .setAudience(Collections.singletonList(clientID))
    .build();
  
  GoogleIdToken idToken = verifier.verify(token);
  if (idToken != null) {
    Payload payload = idToken.getPayload();
    print("Google verify confirmed: " + payload.getEmail());
    ret payload;
  }
  
  print("Google verify failed");
  null;
}

Author comment

Began life as a copy of #1013811

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1013821
Snippet name: googleVerifyUserToken2
Eternal ID of this version: #1013821/3
Text MD5: fb1dc58a4ddeb52b7f2fc903bde8d15e
Transpilation MD5: 06ff259e2c2ed3b3b91d034b7d93cd18
Author: stefan
Category: javax / web
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-07-14 13:13:11
Source code size: 1127 bytes / 32 lines
Pitched / IR pitched: No / No
Views / Downloads: 380 / 473
Version history: 2 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)