Taycan Client Software Development

Austin_yeahbaby

Well-Known Member
Joined
Sep 30, 2019
Messages
320
Reaction score
228
Location
United Kingdom
Vehicles
Taycan 4S, replaced my 911 ;-)
Country flag
just following up my other post re Alexa integration.

Just sharing that I used voiceflow to build the quick test

You can setup a free account with 2 flow but it's pretty easy to get going if anyone want's to have a go.

I can share the config on main API request box if anyone is interested.

Capture.JPG





Advertisement

 

cjne

Active Member
First Name
Johan
Joined
Sep 22, 2020
Messages
36
Reaction score
46
Location
Sweden
Vehicles
Taycan Turbo S 2021, Tesla Model S P100D 2019
Country flag
Just converted your code to PHP for fun. Works great! Will see if I can't get it converted to Kotlin for Android this weekend. Sadly no mac anymore so no Xcode. Guess I'll have to use my old Samsung for funsies.

1611887908551.png

1611890810526.png


Magic mirror next mayhaps? I mean, the API serves you correct images for your vehicle so it could look quite snazzy with some animations and be able to set heating while brushing your teeth f.ex.

Ah, possibilities.
Nice!
I have discovered that some API endpoints require a different apikey, i need to investigate how to get that.
Looks like another id token (jwt) is obtained somehow after initial auth and the api key is kept in there.
 

cjne

Active Member
First Name
Johan
Joined
Sep 22, 2020
Messages
36
Reaction score
46
Location
Sweden
Vehicles
Taycan Turbo S 2021, Tesla Model S P100D 2019
Country flag
just following up my other post re Alexa integration.

Just sharing that I used voiceflow to build the quick test

You can setup a free account with 2 flow but it's pretty easy to get going if anyone want's to have a go.

I can share the config on main API request box if anyone is interested.

Capture.JPG
This looks interesting, i'm not using Alexa myself but i'm still curious, how does the authentication work?
 

Oink

Well-Known Member
Joined
Sep 8, 2020
Messages
86
Reaction score
63
Location
Norway
Vehicles
Audi A4, Taycan 4S+
Country flag
Hi Oink, can you share your php code please ?
Thank you for your work !
Will do. Just got my account temporarily locked due to wrong password while I was cleaning it up before putting it up on github. Will get it up after dinner. I'll include some sample html/jq with it.

Nice!
I have discovered that some API endpoints require a different apikey, i need to investigate how to get that.
Looks like another id token (jwt) is obtained somehow after initial auth and the api key is kept in there.
Let me guess -- status (E-Control)? Gah I want to work on this, not stream. :headbang:
 
OP
AMERCY

AMERCY

Well-Known Member
First Name
Christof
Joined
Oct 30, 2020
Messages
53
Reaction score
48
Location
Germany, Stuttgart region
Vehicles
Macan '19 (Crayon), Taycan 4S+ '21 (Black)
Country flag
  • Thread starter
  • Thread Starter
  • #50
I've published a very basic version of a client library for Python, it can just list cars for your account at the moment but it has the auth part. So from here it's very easy to add stuff.
https://github.com/cjne/pyporscheconnectapi
example2.py, added a (pragmatic) check

if data['carControlData'] is not None:
print(f"Battery at {data['carControlData']['batteryLevel']['value']}%")

in order to make Macan not stop the show.
 

cjne

Active Member
First Name
Johan
Joined
Sep 22, 2020
Messages
36
Reaction score
46
Location
Sweden
Vehicles
Taycan Turbo S 2021, Tesla Model S P100D 2019
Country flag
Let me guess -- status (E-Control)? Gah I want to work on this, not stream. :headbang:
Yeah, the more interesting endpoints, probably including the ones that let you control stuff, require an api key that somehuw match the access token... Will continue with it and if anyone has any input I’d appreciate it :)

example2.py, added a (pragmatic) check

if data['carControlData'] is not None:
print(f"Battery at {data['carControlData']['batteryLevel']['value']}%")

in order to make Macan not stop the show.
That’s a good call, I only have one Taycsn so I didn’t think about that, will update the example :)
 

Oink

Well-Known Member
Joined
Sep 8, 2020
Messages
86
Reaction score
63
Location
Norway
Vehicles
Audi A4, Taycan 4S+
Country flag
That’s a good call, I only have one Taycsn so I didn’t think about that, will update the example :)
Yeah same here. Can't wait to do error handling for various cars and their abilities. Might as well spam try/catch or if/else into everything. Lol.

Hi Oink, can you share your php code please ?
Thank you for your work !
Here you go https://github.com/RiotNOR/phpporscheconnectapi

If you want to make a bunch of ajax calls you'll have to setup your own paths and functions. In the example it just fetches car info by vin directly after login is achieved. You could save the $webSession variable into the php session I guess so you can reuse it.

Do note I did not include any code for handling expiration date since it's all done with one login, so if you do as suggested above then just handle the received expiration that gets captured under "handleApiToken"


Included example looks like this + model logged into console for you:
1611961367337.png
 
Last edited:

cjne

Active Member
First Name
Johan
Joined
Sep 22, 2020
Messages
36
Reaction score
46
Location
Sweden
Vehicles
Taycan Turbo S 2021, Tesla Model S P100D 2019
Country flag
I've finally had some time to work on this again and now the python lib can also access the more interesting parts!
Haven't had time to do anything interesting with it yet though so i'm not sure if this covers the whole api but we'll find out i guess :)
 

Oink

Well-Known Member
Joined
Sep 8, 2020
Messages
86
Reaction score
63
Location
Norway
Vehicles
Audi A4, Taycan 4S+
Country flag
https://github.com/driven-app/porsche-connect

It is still early days for me, but I am starting to release my Swift based API library focused on Apple platforms. I am moving slower than a few folks here but I am also trying to bring documentation and full test suite along as I go.
What's the legality if using the api like we are? I mean, for App store purposes? Apple is pretty strict and it's not exactly a public api. 🤔
 

tigerbalm

Well-Known Member
Joined
Oct 11, 2020
Messages
346
Reaction score
361
Location
Ireland
Vehicles
Panamera Turbo S E-hybrid, Peugeot e-208, Taycan
Country flag
Probably one for the lawyers. The way I view it, is that I am making a custom and narrow focused User Agent based on publicly observable behaviours and am careful not to violate any copyrighted material.

That being said, I'm am using my library for a macOS app and am not planning any distribution through the app stores at this time.

Folks have being doing this with Tesla (https://www.teslaapi.io/#is-this-api-official) for a long time without any apparent issues.
 

tigerbalm

Well-Known Member
Joined
Oct 11, 2020
Messages
346
Reaction score
361
Location
Ireland
Vehicles
Panamera Turbo S E-hybrid, Peugeot e-208, Taycan
Country flag
@cjne I have a brief question on one aspect of your code in relation to the Auth flow.

Screenshot 2021-02-01 at 09.37.50.png


Is the purpose of the POST to the "porscheLoginAuth" endpoint just to get the cookies that are returned. And are those cookies then used in the two "requestToken" calls that you make?

If so, do you know are all the returned cookies required – are you just sending them all up (from your cookie jar) each time you make any subsequent calls?

This bit has me unsure – thank you!
 

cjne

Active Member
First Name
Johan
Joined
Sep 22, 2020
Messages
36
Reaction score
46
Location
Sweden
Vehicles
Taycan Turbo S 2021, Tesla Model S P100D 2019
Country flag
@cjne I have a brief question on one aspect of your code in relation to the Auth flow.

Screenshot 2021-02-01 at 09.37.50.png


Is the purpose of the POST to the "porscheLoginAuth" endpoint just to get the cookies that are returned. And are those cookies then used in the two "requestToken" calls that you make?

If so, do you know are all the returned cookies required – are you just sending them all up (from your cookie jar) each time you make any subsequent calls?

This bit has me unsure – thank you!
Yes, the actual login (POST to "porscheLoginAuth") is generating cookies that are later used in the requests to get tokens.
I'm just sending them all up using the client session in subsequent requests.
The first requests for the login page was not needed by the way, i've pushed a cleaned up version to the repo.

I haven't done any code for session expiration yet, and i would like to investigate the possibility of getting a refresh token, it's not return with the access token and id token but maybe it can be obtained somehow.

Right now my code doesn't have much in way of error checking and tests are completely lacking, i might get around to do that at some point :)
 

Advertisement





 
ZYRUS


Advertisement
Top