Skip to content
This repository has been archived by the owner on Aug 6, 2023. It is now read-only.

Facebook provider not working #17

Open
aspiiire opened this issue Sep 12, 2022 · 0 comments
Open

Facebook provider not working #17

aspiiire opened this issue Sep 12, 2022 · 0 comments

Comments

@aspiiire
Copy link
Contributor

aspiiire commented Sep 12, 2022

Edit, even after checking that everything is updated by creating a new provider, It always returns "Jr: expected 200 OK, got: 401 Unauthorized" even after checking multiple times.

Facebook docs says that it need something like this:

https://www.facebook.com/v14.0/dialog/oauth?
  client_id={app-id}
  &redirect_uri={"https://www.domain.com/login"}
  &state={"{st=state123abc,ds=123456789}"}

I have created a new provider and imported it under [...astroauth].ts as the following example:

import { OAuthConfig, OAuthUserOptions } from '@astro-auth/types';

const FacebookProvider = (options: OAuthUserOptions): OAuthConfig => {
    return {
        id: 'facebook',
        name: 'Facebook',
        type: 'token',
        scope: 'email',
        options,
        authorization: 'https://www.facebook.com/v14.0/dialog/oauth',
        token: 'https://graph.facebook.com/oauth/access_token',
        userinfo: 'https://api.github.com/user',
        profile(profile) {
            return {
                id: profile.id.toString(),
                name: profile.name || profile.login,
                email: profile.email,
                image: profile.avatar_url,
                originalUser: { ...profile },
            };
        },
    };
};

export default FacebookProvider

I have added the redirect inside the facebook app to contain the required path present inside the docs, after login it get's stuck after receiving the code that I see in the params and returns Jr: expected 200 OK, got: 401 Unauthorized

Google provider works perfectly

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant