Skip to content
This repository was archived by the owner on Oct 27, 2021. It is now read-only.
This repository was archived by the owner on Oct 27, 2021. It is now read-only.

Can fetch Token, but when using it get Unauthorized error #17

@ubenmackin

Description

@ubenmackin

I've been able to successfully use the python script (or ruby script) to pull down a token just fine. However, when I try and use that with Tim's ruby gem (https://github.com/timdorr/tesla-api), I get a 404 Unauthorized. I wanted to make sure I am using this correctly.

First I run a script to get a token:

macbookair:tesla-oauth2 kupan787$ python3 tesla.py -e bXXXXXX@mXXXX.com -p wxxxxxxxe --verbose
Post auth form success - 1 attempt(s).
Code - ['5460d1ba24..........983322f3e871.................2169c90']

Then I put that code in my ruby script:

tesla_api = TeslaApi::Client.new(access_token: "5460d1ba24..........983322f3e871.................2169c90")

But when I run my ruby script, I get the following:

macbookair:tesla-oauth2 kupan787$ ./getTeslaStats.rb
Traceback (most recent call last):
11: from ./getTeslaStats.rb:16:in <main>' 10: from /var/lib/gems/2.7.0/gems/tesla_api-3.1.0/lib/tesla_api/client.rb:158:in vehicles'
9: from /var/lib/gems/2.7.0/gems/tesla_api-3.1.0/lib/tesla_api/client.rb:150:in get' 8: from /var/lib/gems/2.7.0/gems/faraday-1.3.0/lib/faraday/connection.rb:198:in get'
7: from /var/lib/gems/2.7.0/gems/faraday-1.3.0/lib/faraday/connection.rb:492:in run_request' 6: from /var/lib/gems/2.7.0/gems/faraday-1.3.0/lib/faraday/rack_builder.rb:154:in build_response'
5: from /var/lib/gems/2.7.0/gems/faraday_middleware-1.0.0/lib/faraday_middleware/request/encode_json.rb:26:in call' 4: from /var/lib/gems/2.7.0/gems/faraday_middleware-1.0.0/lib/faraday_middleware/response_middleware.rb:36:in call'
3: from /var/lib/gems/2.7.0/gems/faraday-1.3.0/lib/faraday/middleware.rb:18:in call' 2: from /var/lib/gems/2.7.0/gems/faraday-1.3.0/lib/faraday/response.rb:59:in on_complete'
1: from /var/lib/gems/2.7.0/gems/faraday-1.3.0/lib/faraday/middleware.rb:19:in block in call' /var/lib/gems/2.7.0/gems/faraday-1.3.0/lib/faraday/response/raise_error.rb:18:in on_complete': the server responded with status 401 (Faraday::UnauthorizedError)

Is the token I get from this not to be used in the ruby TeslaApi::Client.new call? Any help is appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions