huandu / facebook

A Facebook Graph API SDK For Go.
https://pkg.go.dev/github.com/huandu/facebook
MIT License
1.34k stars 517 forks source link

Add option to pass access_token in Authorization header instead of query parameter #205

Closed sbellity closed 1 year ago

sbellity commented 1 year ago

This proposal allows to pass the access_token as Authorization header to FB api instead of query parameter. Does not change the current behavior which is still the default, but adds a UseAuthorizationHeader on the session to enable this feature.

example use:

func newFacebookSession(ctx context.Context, accessToken string) facebook.Session {
        session := facebook.Session{}.WithContext(ctx)
        session.SetAccessToken(accessToken)
    session.UseAuthorizationHeader()
        return session
}
huandu commented 1 year ago

LGTM. Thanks for your contribution!