Search code examples
pythongoogle-oauthgoogle-api-python-client

In Python, how do you use the Google Apps Domain Key to connect to Google API?


I can't connect to my Google Calendar using the Domain Key, i.e. the consumer key with the same name as the domain name.

I'm using the the OAuth2WebServerFlow, Credentials and Storage objects as guided here: https://developers.google.com/api-client-library/python/guide/aaa_oauth

flow = OAuth2WebServerFlow(client_id="domain.com",
                           client_secret=<Consumer Secret>,
                           scope='https://www.googleapis.com/auth/calendar')

But, I just get an "invalid_client" error when I go to the website for authentication.

Does anybody have any tips for getting this to work? I have no issues getting OAuth keys that I generate from the API console working. But, I'm struggling with the domain key, specifically. Is there something special that you have to do?


Solution

  • This is for OAuth 2.0 and hence you need the actual Client ID, not your domain. (It seems like you're getting this mixed up with OAuth 1.0 a bit, but maybe I'm misunderstanding.)

    Check out the Google APIs Console docs for more information on what a Client ID is and where you can find it.