@Override public Identity identity() throws IOException { Identity identity = Identity.ANONYMOUS; if (this.resource.uriInfo().getQueryParameters() .containsKey(Facebook.FLAG)) { final List<String> code = this.resource.uriInfo() // @checkstyle MultipleStringLiterals (1 line) .getQueryParameters().get("code"); if (code == null || code.isEmpty()) { throw new WebApplicationException( new IllegalArgumentException( "HTTP query parameter 'code' is mandatory" ), HttpURLConnection.HTTP_BAD_REQUEST ); } final User fbuser = this.fetch(this.token(code.get(0))); identity = new Identity.Simple( URN.create(String.format("urn:facebook:%s", fbuser.getId())), fbuser.getName(), UriBuilder.fromUri("https://graph.facebook.com/") .path("/{id}/picture") .build(fbuser.getId()) ); } return identity; }
String firstName = me.getFirstName(); String lastName = me.getLastName(); String name = me.getName(); Boolean verified = me.getVerified();
@Override public Opt<Identity> enter(final Request trequest) throws IOException { final Href href = new RqHref.Base(trequest).href(); final Iterator<String> code = href.param(PsFacebook.CODE).iterator(); if (!code.hasNext()) { throw new HttpException( HttpURLConnection.HTTP_BAD_REQUEST, "code is not provided by Facebook" ); } final User user = this.fetch( this.token(href.toString(), code.next()) ); final Map<String, String> props = new HashMap<>(0); props.put("name", user.getName()); props.put( PsFacebook.PICTURE, new Href("https://graph.facebook.com/") .path(user.getId()) .path(PsFacebook.PICTURE) .toString() ); return new Opt.Single<>( new Identity.Simple( String.format("urn:facebook:%s", user.getId()), props ) ); }
@Override public Opt<Identity> enter(final Request trequest) throws IOException { final Href href = new RqHref.Base(trequest).href(); final Iterator<String> code = href.param(PsFacebook.CODE).iterator(); if (!code.hasNext()) { throw new HttpException( HttpURLConnection.HTTP_BAD_REQUEST, "code is not provided by Facebook" ); } final User user = this.fetch( this.token(href.toString(), code.next()) ); final Map<String, String> props = new HashMap<>(0); props.put("name", user.getName()); props.put( PsFacebook.PICTURE, new Href("https://graph.facebook.com/") .path(user.getId()) .path(PsFacebook.PICTURE) .toString() ); return new Opt.Single<>( new Identity.Simple( String.format("urn:facebook:%s", user.getId()), props ) ); }