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

Remove access token for profile picture URL #388

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Rubyist007
Copy link

Access token for profile picture URL is not necessary and could lead to problems with expired access tokens when URL stored in DB

This pull request removes the access token param in the image URL, which resolves the issue I posted: #387

Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@Rubyist007
Copy link
Author

I made a tiny update of the readme corresponding to the changes

@simi
Copy link
Owner

simi commented May 19, 2024

What about to provide 2 methods to cover both variants (app scoped id and user id)? Or any other way to keep both variants working? Maybe additional argument or so?

@Rubyist007
Copy link
Author

Thanks for your response @simi!

What about to provide 2 methods to cover both variants (app scoped id and user id)? Or any other way to keep both variants working? Maybe additional argument or so?

I'm not sure what exactly you are mean, in this PR there are no changes related to app scoped id or user id

How I can see (UID) is passed as an argument to an image_url method and in this PR we don't affect this argument

def image_url(uid, options)
uri_class = options[:secure_image_url] ? URI::HTTPS : URI::HTTP
site_uri = URI.parse(client.site)
url = uri_class.build({host: site_uri.host, path: "#{site_uri.path}/#{uid}/picture"})
query = { access_token: access_token.token }
if options[:image_size].is_a?(String) || options[:image_size].is_a?(Symbol)
query[:type] = options[:image_size]
elsif options[:image_size].is_a?(Hash)
query.merge!(options[:image_size])
end
url.query = Rack::Utils.build_query(query)
url.to_s
end

If you mean that we should support behaviour that received UID will be user-id and for that case, we will need access_token in our URL to get the image
In that case, I'm not sure if such a case could happen, how received UID can be user-id if the gem uses app access tokens?
That's why we need to provide FACEBOOK_APP_ID and FACEBOOK_APP_SECRET and use the Facebook app access token (Facebook doc)

option :client_options, {
site: "https://graph.facebook.com/#{DEFAULT_FACEBOOK_API_VERSION}",
authorize_url: "https://www.facebook.com/#{DEFAULT_FACEBOOK_API_VERSION}/dialog/oauth",
token_url: 'oauth/access_token'
}

User uid for picture url we take from /me endpoint (Facebook doc) that works the same as user endpoint (Facebook doc)

def raw_info
@raw_info ||= access_token.get('me', info_options).parsed || {}
end
def info_options
params = {appsecret_proof: appsecret_proof}
params.merge!({fields: (options[:info_fields] || 'name,email')})
params.merge!({locale: options[:locale]}) if options[:locale]
{ params: params }
end


'image' => image_url(uid, options),

And the Facebook documentation tells us that returned ID is App-Scoped User ID

The app user's App-Scoped User ID. This ID is unique to the app and cannot be used by other apps.

So for me, it looks like there is no way that we could use another type of ID

If I missing some use cases when gem could use user id instead of app scoped id or misunderstood the way of gem behaviour please let me know

@github-actions github-actions bot closed this May 26, 2024
@simi simi reopened this May 26, 2024
@github-actions github-actions bot closed this Jun 1, 2024
@simi simi reopened this Jun 1, 2024
@github-actions github-actions bot closed this Jun 7, 2024
@simi simi reopened this Jun 7, 2024
@github-actions github-actions bot closed this Jun 13, 2024
@Rubyist007
Copy link
Author

Hi @simi
I see that you reopened this PR 3 times so I believe that this PR is interesting for you
Waiting for your comment or any action related to it

I just don't want this PR to become forgotten without some final decision about it, so just pinging you

@simi simi reopened this Jun 19, 2024
@simi
Copy link
Owner

simi commented Jun 19, 2024

Yup, I need to disable this auto-closing somehow.

@Rubyist007
Copy link
Author

I believe behaviour with auto-closing PR could be edited here: https://github.com/simi/omniauth-facebook/blob/master/.github/workflows/stale.yml

It looks like it closes PR with no activity in 5 days based on this line:

days-before-close: 5

@simi
Copy link
Owner

simi commented Jun 19, 2024

Thanks @Rubyist007, updated ca9b64f. I'll try to find some time to revisit this, since I think I'm mixing 2 issues together here probably and I don't fully follow for now.

@Rubyist007
Copy link
Author

Welcome

Yep sure, no problem

@github-actions github-actions bot closed this Aug 19, 2024
@Rubyist007
Copy link
Author

@simi Hi
Just a kind reminder about PR

@simi simi reopened this Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants