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

[Bug]: Facebook and Google Login #6

Open
1 task done
mthnzbk opened this issue Dec 30, 2022 · 9 comments
Open
1 task done

[Bug]: Facebook and Google Login #6

mthnzbk opened this issue Dec 30, 2022 · 9 comments
Assignees
Labels
help wanted Extra attention is needed

Comments

@mthnzbk
Copy link

mthnzbk commented Dec 30, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Environment

-   OS: W11
-   Python:3.10

What happened?

`Traceback (most recent call last):
File "C:\Users\venv\lib\site-packages\firebase_exception.py", line 13, in raise_detailed_error
request_object.raise_for_status()
File "C:\Users\venv\lib\site-packages\requests\models.py", line 1021, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://www.googleapis.com/identitytoolkit/v3/relyingparty/createAuthUri?key=AIzaSyDFP8PMnJzIl-4q8fsnkz1uvEPE3nHivcA

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\main.py", line 34, in
print(auth.authenticate_login_with_facebook())
File "C:\Users\venv\lib\site-packages\firebase\auth_init_.py", line 78, in authenticate_login_with_facebook
return self.create_authentication_uri('facebook.com')
File "C:\Users\venv\lib\site-packages\firebase\auth_init_.py", line 127, in create_authentication_uri
raise_detailed_error(request_object)
File "C:\User\venv\lib\site-packages\firebase_exception.py", line 17, in raise_detailed_error
raise HTTPError(e, request_object.text)
requests.exceptions.HTTPError: [Errno 400 Client Error: Bad Request for url: https://www.googleapis.com/identitytoolkit/v3/relyingparty/createAuthUri?key=AIzaSyDFP8PMnJzIl-4q8fsnkz1uvEPE3nHivcA] {
"error": {
"code": 400,
"message": "INVALID_CONTINUE_URI",
"errors": [
{
"message": "INVALID_CONTINUE_URI",
"domain": "global",
"reason": "invalid"
}
]
}
}`

I think I entered the information correctly. this is the error I get.
auth = firebase.auth(client_secret="client_secret.json") auth.authenticate_login_with_facebook()
client_secret.json:
{ "client_id": "1234", "client_secret": "1a2s", "redirect_uris": "https://xxx.firebaseapp.com/__/auth/handler" }

Code Snippet

import firebase

config = {
    "apiKey": "-",
    "authDomain": ".firebaseapp.com",
    "databaseURL": "https://.europe-west1.firebasedatabase.app",
    "projectId": "",
    "storageBucket": ".appspot.com",
    "messagingSenderId": "",
    "appId": "1::android:",
    "serviceAccount": "firebase.json"
}

firebase = firebase.initialize_app(config)
auth = firebase.auth(client_secret="client_secret.json")
print(auth.authenticate_login_with_facebook())

Relevant log output

No response

Anything else?

No response

@mthnzbk mthnzbk added bug Something isn't working triage labels Dec 30, 2022
@github-actions
Copy link

Hello @mthnzbk , thank you for submitting an issue! A project committer will shortly review the issue.

@AsifArmanRahman
Copy link
Owner

The key redirect_uris in the client secret file is supposed be an array, not a string.

Please try reformatting it in the following example:

{ 
    "client_id": "1234", 
    "client_secret": "1a2s",
    "redirect_uris": ["https://xxx.firebaseapp.com/__/auth/handler"]
}

@AsifArmanRahman AsifArmanRahman added help wanted Extra attention is needed and removed bug Something isn't working triage labels Dec 30, 2022
@AsifArmanRahman AsifArmanRahman self-assigned this Dec 30, 2022
@mthnzbk
Copy link
Author

mthnzbk commented Dec 31, 2022

"Unable to process request due to missing initial state. This may happen if browser sessionStorage is inaccessible or accidentally cleared." -> When I click on the link and authorize, the firebase link gives this output.

@AsifArmanRahman
Copy link
Owner

  1. Did you add the redirect uri to the list of authorized redirect URIs for your OAuth app? If you didn't, please do that.
  2. Try opening the link with a different browser.
  3. Also, there is an ongoing issue opened in firebase-js-sdk facing the same issue. I guess the default callback URL has some issue. Could you try using an own built callback URL?

@Lxstr
Copy link

Lxstr commented Mar 19, 2023

Would like your thoughts on including this in the auth docs as it can be a bit confusing when you realise client secret is both the object and within the object. I have remove references to config.py (ie BaseConfig.CLIENT_SECRET), if that is more general.

Client secret as a json file or dict must be passed when using SSO (just google) functions.

auth = app.auth(client_secret=CLIENT_SECRET)

CLIENT_SECRET = {"web": { 
                "client_id": environ.get("CLIENT_ID"), 
                "client_secret": environ.get("CLIENT_SECRET"),
                "redirect_uris": [environ.get("REDIRECT_URI")]
            }}

or

auth = firebase.auth(client_secret="client_secret.json")

client_secret.json format:

{ 
    "client_id": "1234", 
    "client_secret": "1a2s",
    "redirect_uris": ["https://xxx.firebaseapp.com/__/auth/handler"]
}

AsifArmanRahman added a commit that referenced this issue Mar 24, 2023
@kengoon
Copy link

kengoon commented Mar 31, 2023

please where can i get this client_secret.json

@AsifArmanRahman
Copy link
Owner

@kengoon Create an API key

@AlexJrDevs
Copy link

Where do you get the redirect_uris, I can see one in OAuth but doesn't work. Also my redirect_uris look like http://localhost not like the one you've mentioned. Can someone help me out?

@AlexJrDevs
Copy link

Where do you get the redirect_uris, I can see one in OAuth but doesn't work. Also my redirect_uris look like http://localhost not like the one you've mentioned. Can someone help me out?

As soon as I post this I figured it out, sorry. You have to go to your authentication settings in firebase and click authorized domains, find the link which ends in .com and paste it: https://paste_here/__/auth/handler After this, I'm unsure how to get rid of as I added the redirect uri to the authorized apps in google cloud.

"Unable to process request due to missing initial state. This may happen if browser sessionStorage is inaccessible or accidentally cleared. Some specific scenarios are - 1) Using IDP-Initiated SAML SSO. 2) Using signInWithRedirect in a storage-partitioned browser environment."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants