i'm receiving that profile image picture now, i didn't change anything in my configuration (it worked fine before, and that user is me and i have a profile picture).
# config/initializers/omniauth.rb
Rails.application.config.middleware.use OmniAuth::Builder do
provider(
:facebook,
ENV.fetch("FACEBOOK_APP_ID"),
ENV.fetch("FACEBOOK_APP_SECRET"),
image_size: :large,
)
end
# app/controllers/sessions_controller.rb
def facebook
uid = auth_hash["uid"]
email = auth_hash["info"]["email"]
image_url = auth_hash["info"]["image"]
name = auth_hash["info"]["name"]
first_name = name.split.first
# ...
attach_image_from_url(@user, image_url)
# ...
end
private
def auth_hash
request.env["omniauth.auth"]
end
def attach_image_from_url(user, image_url)
# return if user.image.attached?
image = Down.download(image_url)
user.image.attach(io: image, filename: "image.jpg")
end
anything i'm missing ?
edit: i tried the setting the api version to 7.0 (it was 4.0) and it seems like the /picture endpoint has disappeared https://developers.facebook.com/docs/graph-api/changelog/version4.0/
Upgrading to ominauth-facebook 8.0.0 (from 7.0.0) and setting secure_image_url: true
fixed it
Rails.application.config.middleware.use OmniAuth::Builder do
provider(
:facebook,
ENV.fetch("FACEBOOK_APP_ID"),
ENV.fetch("FACEBOOK_APP_SECRET"),
image_size: :large,
secure_image_url: true,
)
end
without secure_image_url: true
i get a 500 error, see https://github.com/simi/omniauth-facebook/pull/346