Help to define Jsonfactory
@dan1st | Daniel
Can you help me to write
JsonFactory
bean?
I got this error:
The BloggerServiceConfiguration
is:
I try to define the JsonFactory
:
But JacksonFactory
is underlined in red - JacksonFactory cannot be resolved
The com.google.api.client.json.jackson2..
is obsolete.
Now jackson comes from:
But how to use it in bean?78 Replies
⌛
This post has been reserved for your question.
Hey @Tomasm21! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
Can you show the full stack trace/error? What's the package of the main class? What's the package of
GoogleApiConfiguration
?No stack trace. I cannot start the app. package:
also you need google-http-client-jackson2 for
JacksonFactory
not just jackson-coreI kinda tried it. But then Jaksonfactory was underlined in yellow and it says that deprecated
ok I will try again
oh right
to use Gsonfactory
mmm
Should I add this: https://mvnrepository.com/artifact/com.google.code.gson/gson/2.10.1
and specifically
google-http-client-gson
instead of google-http-client-jackson2
I hope this is ok:
you probably don't need jackson-core any more
but yeah looks alright
I don't get it:
the package name is different
remove the import
and let autocomplete create the import
I think it would be
com.google.api.client.json.gson.GsonFactory
or something like thatright
But I'm not sure this is ok
probably ok, yeah
alternatively you could use
GsonFactory.getDefaultInstance()
ok
Gson is now ok. Please, - help me to fix the
BloggerServiceConfiguration
.idk what is there to fix
you don't need
@Value
on your field if you have it in the constructor
authorizedClientService.loadAuthorizedClient(googleClientId, null);
I think the null
here is the issueyes I think it too.
OAuth2AuthorizedClientService (spring-security-docs 6.2.4 API)
declaration: package: org.springframework.security.oauth2.client, interface: OAuth2AuthorizedClientService
the name of the End-User Principal (Resource Owner)
I want to use Google's Blogger service through Blogger API. To create there blogs and add images using my SB app.
I don't authenticate to my Spring Boot app using OAuth2
I have my default username and password system. Users are saved to local database
But I don't know what exactly to use as the resource owner
I created
Web client 1
on Google Cloud Credentials and I got Client ID and Client Secret.
I save d those values to the application.propertiesI think
loadAuthorizedClient
is for users trying to connect with your application
but idkAI says it's my principal name if my Spring Boot app authenticates using OAuth2.
But it's not the case. I have my custom authentication mechanism like I told.
So I don't need to use
OAuth2AuthorizedClient
at all
I will try to access Google's Blogger API without so called OAuth2
But in my application properties I have:
But here it says about authentication:
https://developers.google.com/blogger/docs/3.0/using
Google for Developers
Blogger API: Using the API | Google for Developers
Learn to set up and authorize the Blogger API to integrate Blogger content with your application.
I think this method is used in case your application is an OAuth2 server
so if the client authenticates to your application, not for something to interact with Google APIs
What do you want to access? Do you want the user to give you access to something? If yes, you need OAuth2
yeah these things are necessary if you want to do something like
- Let users sign in with their Google account
- Access something associated with the Google account of users after the users consented
No Dan
I will tell you what exactly I want to do.
When users make an order in our not real yet e-commerce web app then Order Invoice is created as email-template.html. using Thymeleaf. And I need to add ordered products images to HTML table. Ther are three ways - as content ID, inline embedded image or hosted images url links. Content Ids, and embedded images fail. Gmail and Hotmail blocks them and images are not showed in such an email. But hosted online images URLs works. I tested with real images that were added to my test blog on Blogger. I copied URL and posted into the email-template.html. And in email it was showing.
So my purpose is to automate the process.
When Order is created at my app then all ordered products images should be taken from the disk and sent to Blogger
Automatic process
And Blogger should provide me links - URLs
that I will add to template and send to user's email
Just my Spring should be able to send requests to Blogger API
and get responses
On behalf of my real account
idk blogger
but it doesn't look like you need OAuth2 for that
you need OAuth2 if you want to do it on behalf of the user
I think I need Client ID and Client Secret so Blogger API would recognize me as Google account user.
though if you want to create a blog, that might need to be done on behalf of a user
Regarding OAuth2 I;m not sure
For OAuth2, you need a user allowing you to access it on behalf of them
client id and cölient secret are specific to OAuth2
But why do you need blogger?
It's free
for AWS S3 you have to pay
ah
I don't plan to send there tons of images
But when I added some images:
I was able to get its Urls
and paste inside the email_template
Can't you host the image on your website?
and in email it was showing
it's on localhost
And then just refer to these images in your E-Mail?
well once you run it in production, it will no longer be on localhost
I know.
And I don't know how to host
that's why I need third party host service
just store the images on your server?
and make an endpoint for retrieving them
I don't have a server. Is my Spring Boot app on localhost a server?
can gmail access images from it?
or hotmail
yes
though if you want to allow other users to access your Spring Boot app, you cannot have it on localhost
I know.
But right now I seek to test as a user myself
you can just use it
make an endpoint that allows you to get the image
e.g.
/images/yourimage.jpg
and then in your E-Mail, you can do <img src="http://localhost/images/yourimage.jpg" />
I have endpoint that returns whole list of product objects including its images but as
private byte[] image1;
Should I make an endpoint for an image
an Image requested by its name?You need an endpoint allowinjg you to request a specific image
by name, by id or by whatever
you need some way to get an image
and then link to that in your E-Mail
Will it really work?
I will make it
If it will really work even if my app is on localhost and my computer has Internet connection
it should work. Once you need to refer to the endpoint with
http://localhost:YOUR_PORT/PATH/TO/THE/ENDPOINT/WITH/YOUR/IMAGE
in your E-MailI will try it
Thanks for an offer
I will close this if I will succeed.
I really made an endpoint and it really works locally. But when I send an email-template invoice with images then images are not displayed.
If I open an image locally in a browser it is perfectly showing.
Can you show what's shown in the E-Mail client?
yes.. One moment..
Service method fragment:
Remaining fragment:
Console output:
Local image:
of the
http://localhost:9400/product/image/banana5.jpg
But initial reequest was called from the frontend:
2 products - bananas and tomatoes
It was successful request and response.
Database is filled with the order.
Just email with empty images.
And the controller for image return:
And its service method:
I'm sure that is because of the localhost.
If I would add an image with public URL then the image inside the email message would be shown
I already tried.
If my project would be in production (on public server) then the image would be shown in the email. I'm sure of it.
And right now I am trying to configure Blogger API.
Everything there becomes public.
I need automatic images upload from my server in localhost to Google's Blogger.
what'S shown when hovering over an image?
yeah that will probably not work if you use the gmail website
I thought you would use a proper local E-Mail client on your machine
Just use a normal E-Mail client
and you can test it with one that runs in your browser as soon as you have deployed it
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
On desktop PC I don't use local client programs for gmail. It's enough to open my gmail email service in browser.
Well if you want it to work, you need a local client
once you put it on a proper domain, that shouldn't be necessary any more
On mobile phone I have special local program "Gmail" that also opens my inbox. And I recently checked it out. There are no images too. And also when you hover mouse pointer over an image it also doesn't make an image to appear.
Well it needs to be available on localhost
which is the case on your computer while the server is running
your mobile is not your computer
and the gmail server is also not running on your computer
I think that on local client for gmail on desktop pc the result would be the same.
For remote gmail server
localhost
means internal network for that remote gmail server. And it doesn't have hosted endpoint to get the image.idk what gmail does
Except that you are sure that localhost should really work through remote gmail server.
but normal E-Mail clients that are not specific to the provider don't have that problem
Gmail and hotmail as massive world level email providers should be normal. Maybe I don't know what is client.
Or maybe you are laughing at me and say that Gmail should be local on my local network and only then I would get images in my inbox.
All in all, - most likely I should make public url links to my images.
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.