astro-community / astro-auth

The Easiest Way To Do Authentication In Astro 🧑🏻‍🚀

Home Page:astro-auth-docs.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Facebook provider not working

aspiiire opened this issue · comments

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