GithubHelp home page GithubHelp logo

Comments (15)

tylertreat avatar tylertreat commented on May 21, 2024

Can you verify the key you're reading in is a valid PKCS12 or PEM key? This error occurs if the string isn't a valid key.

from bigquery-python.

thinksource avatar thinksource commented on May 21, 2024

@tylertreat can you explain more clearly?

mykey is generate form
https://console.developers.google.com/project/foretribebigquery/apiui/credential

I generate server key:

Client ID for web application

Client ID
876306077634-b81mhps17flaq8r5fprqrb8cugjj66ro.apps.googleusercontent.com
Email address
876306077634-b81mhps17flaq8r5fprqrb8cugjj66ro@developer.gserviceaccount.com
Client secret
YdV3Rt5Br-lKy5lhqf5ZqY8C
Redirect URIs

    http://localhost:8080/

Javascript Origins

    http://localhost:8080/

from bigquery-python.

tylertreat avatar tylertreat commented on May 21, 2024

You need to create a client id for service account.

service accoubt

This will download a .p12 file to your machine which is the key you should use.

from bigquery-python.

thinksource avatar thinksource commented on May 21, 2024

I did it but still get error.

untitled

from bigquery-python.

tylertreat avatar tylertreat commented on May 21, 2024

Did you mean to include an image? I don't see anything...

from bigquery-python.

thinksource avatar thinksource commented on May 21, 2024

hi @tylertreat can you see it?

from bigquery-python.

tylertreat avatar tylertreat commented on May 21, 2024

Yes, your image shows a client id for web application. You need to create a client id for service account. Then use the key it downloads to your machine.

from bigquery-python.

tylertreat avatar tylertreat commented on May 21, 2024

It should look something like this:

service account

from bigquery-python.

thinksource avatar thinksource commented on May 21, 2024

Does the secret_key equals private key in json file?
the key begin after "-----BEGIN PRIVATE KEY-----\n" or including all of them?
"private_key": "-----BEGIN PRIVATE KEY-----\nMIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBALJMlDzSxPlodfrc\nkTnnBi9M1gsXmkZzuupIO8tpXGiYiQo4QXHsIr2HyG10zB0q11qSTKMFaSar/YeE\nYGsdR6b5nESSuOu2NfZXOHIbUfVXvq1JuTOkjQW0oM9ixbqN1hX3H84R3rHPq4SY\n9Yakud2yq4rcFT5yhjyW5yBcFdJBAgMBAAECgYBmy2/LgVi+0lLyxqeT0nXmX04o\nJvtzEtX4rJyMsbntM8QOeFCC9bkxvE75jBUB2+k89ovokP4GpbINp2xPVRoxWqh5\nfpCE0TWlL1Q+EbB09NPcFIpk7R+VwlwtvkMHZ9LoAo4gVa5U4mscBV3mnOJC0shJ\n9RlHB1evt41ATTr6AQJBAOx7s+RH22yEQ22aqBxn7BvswA/HFay+hCix3bCG79oI\nCuO0lb0AIT/4etPnS4Ae1s1wgLH85k6xpJADDwfd6AkCQQDBA5e7+o2ltsAolyPF\nCRp9EyBkIDvWR1vcyncEyn0Cp4GUmMj5HO9NhIruj9t0xAGahJ1zhJ0U7vFbvSar\nB3Z5AkEAwS+lG53gENxTwRwQrXPwHDfiBoGaoU3Z5Oy4r9br5e+gBbimgomyn/G7\nVZSjxvxqedWoLL7u3eadCtCU3NZZEQJAGjqswgTYfu6IyntPhxUnnludCT5AI2xr\nFWQGLIZ/2n58436nwQKnmncqkiTGg+Wm+iKPawVYe2HFNtxLhu5qsQJBAJVAAF2n\nE+3hIxa+kCZJq4wQkkYMkZl7pke8d8/EV67Nh9jzdMBK6ZLTdIhbm9XuwiGp23m+\n+EuUfaJ2iIkIhYk\u003d\n-----END PRIVATE KEY-----\n"

from bigquery-python.

tylertreat avatar tylertreat commented on May 21, 2024

Yes, or the .p12 key.

I also added a new private_key_file kwarg which lets you provide the file name instead of reading it into a string.

NOTE: this key is PRIVATE and should not be shared with anyone. Now that you've posted it online here, you need to generate a new, secure one.

from bigquery-python.

thinksource avatar thinksource commented on May 21, 2024

Do you know why after:

client=get_client(project_id, service_account=service_account, private_key=secret_key, readonly=True)

get the error:

Error: [('asn1 encoding routines', 'ASN1_CHECK_TLEN', 'wrong tag'), ('asn1 encoding routines', 'ASN1_ITEM_EX_D2I', 'nested asn1 error')]

from bigquery-python.

tylertreat avatar tylertreat commented on May 21, 2024

Are you using the .p12 key?

from bigquery-python.

thinksource avatar thinksource commented on May 21, 2024

This is my .p12 key.
https://drive.google.com/file/d/0B9ncCBd_xIXqZDhKRktYLVI5dms/view?usp=sharing
But after I use it to authority:

client=get_client(project_id, service_account=service_account, private_key_file="key.p12", readonly=True)

get an error is:

Traceback (most recent call last):
File "C:\Python27\lib\site-packages\flask\app.py", line 1836, in call
return self.wsgi_app(environ, start_response)
File "C:\Python27\lib\site-packages\flask\app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "C:\Python27\lib\site-packages\flask\app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "C:\Python27\lib\site-packages\flask\app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "C:\Python27\lib\site-packages\flask\app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\Python27\lib\site-packages\flask\app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "C:\Python27\lib\site-packages\flask\app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Python27\lib\site-packages\flask\app.py", line 1461, in dispatch_request
return self.view_functionsrule.endpoint
File "C:\personal\foretribebigquery\app\routes\index.py", line 41, in googledata
client=get_client(project_id, service_account=service_account, private_key_file="key.p12", readonly=True)
File "C:\personal\foretribebigquery\bigquery\client.py", line 85, in get_client
readonly=readonly)
File "C:\personal\foretribebigquery\bigquery\client.py", line 103, in _get_bq_service
service = build('bigquery', 'v2', http=http)
File "C:\Python27\lib\site-packages\oauth2client\util.py", line 135, in positional_wrapper
return wrapped(_args, *_kwargs)
File "C:\Python27\lib\site-packages\googleapiclient\discovery.py", line 198, in build
resp, content = http.request(requested_url)
File "C:\Python27\lib\site-packages\oauth2client\util.py", line 135, in positional_wrapper
return wrapped(_args, *_kwargs)
File "C:\Python27\lib\site-packages\oauth2client\client.py", line 530, in new_request
self._refresh(request_orig)
File "C:\Python27\lib\site-packages\oauth2client\client.py", line 744, in _refresh
self._do_refresh_request(http_request)
File "C:\Python27\lib\site-packages\oauth2client\client.py", line 807, in _do_refresh_request
raise AccessTokenRefreshError(error_msg)
AccessTokenRefreshError: invalid_grant

from bigquery-python.

thinksource avatar thinksource commented on May 21, 2024

Do the p12 file will read directly?
on your client.py

        with open(private_key_file, 'rb') as key_file:
            private_key = key_file.read()

from bigquery-python.

tylertreat avatar tylertreat commented on May 21, 2024

Yeah, that should work. The json file won't work.

On Mon, Jan 26, 2015, 5:59 PM thinksource [email protected] wrote:

Do the p12 file will read directly?
on your client.py

    with open(private_key_file, 'rb') as key_file:
        private_key = key_file.read()


Reply to this email directly or view it on GitHub
#41 (comment)
.

from bigquery-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.