You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to obtain the authorization code, instead of been redirected to the 404 page that contains the code, I get redirected back to the login page. Which indicates the request is somehow wrong but I can't find out what is is.
<HTML>
<HEAD>
<TITLE>Access Denied</TITLE>
</HEAD>
<BODY>
<H1>Access Denied</H1>
You don't have permission to access "http://auth.tesla.com/oauth2/v3/authorize?"
on this server.<P>
Reference #18.39051702.1666858488.2844a603
</BODY>
</HTML>
I've been able to authorize manually via the .cn site so I don't think this is the issue. But if any one knows why I get the above error please say because I have no idea why.
Next I send the post request. In the request I've got the: tesla-auth.sid cookie, hidden form fields, identity parameter, credential parameter and all the parameters mentioned in the api. But this request just returns the same html page that I had before.
Hers's my Code in C#, I call this Authenticate method with the user details, the response for PostPassword should be the 404 but instead it just redirects back to the login.
publicasyncTaskAuthenticate(UserPassDtouser){// Get OAuth PageRestClientOptionsoptions=new(){BaseUrl=newUri($"https://auth.tesla.cn/oauth2/v3/authorize?client_id=ownerapi&code_challenge={codeChallnge}&code_challenge_method=S256&redirect_uri=https://auth.tesla.com/void/callback&response_type=code&scope=openid%20email%20offline_access&state={state}&login_hint={user.Username}"),};varclient=newRestClient(options);varrequest=newRestRequest("",Method.Get);varresponse=awaitTask.Run(()=>client.Execute(request));varheader=response.Headers.First(x =>x.Name=="Set-Cookie"&&((string)x.Value).Contains("tesla-auth.sid"));stringcookie=((string)header.Value).Split(';').First().Split('=')[1];varformFields=GetFormFields(response.Content);varpasswordResponse=awaitPostPassword(formFields,user,cookie);}privateasyncTask<RestResponse>PostPassword(Dictionary<string,string>formFields,UserPassDtouser,stringcookie){varoptions=newRestClientOptions(){BaseUrl=newUri($"https://auth.tesla.cn/oauth2/v3/authorize?client_id=ownerapi&code_challenge={codeChallnge}&code_challenge_method=S256&redirect_uri=https%3A%2F%2Fauth.tesla.com%2Fvoid%2Fcallback&response_type=code&scope=openid+email+offline_access&state={state}&login_hint={user.Username}"),FollowRedirects=false};varclient=newRestClient(options);varrequest=newRestRequest("",Method.Post);request.AddHeader("cookie",$"tesla-auth.sid={cookie}");request.AddHeader("Content-Type","application/x-www-form-urlencoded");foreach(KeyValuePair<string,string>entryinformFields){request.AddParameter(entry.Key,entry.Value);}request.AddParameter("identity",user.Username);request.AddParameter("credential",user.Password);varresponse=awaitTask.Run(()=>client.Execute(request));returnresponse;}privatestaticDictionary<string,string>GetFormFields(stringcontent){varhiddenFields=Regex.Matches(content,"type=\\\"hidden\\\" name=\\\"(.*?)\\\" value=\\\"(.*?)\\\"");varformFields=newDictionary<string,string>();foreach(MatchmatchinhiddenFields){formFields[match.Groups[1].Value]=match.Groups[2].Value;}returnformFields;}
Any help would be greatly appreciated.
Thanks - Matt
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
When trying to obtain the authorization code, instead of been redirected to the 404 page that contains the code, I get redirected back to the login page. Which indicates the request is somehow wrong but I can't find out what is is.
Steps.
First I fetch the login page:
https://auth.tesla.cn/oauth2/v3/authorizeclient_id=ownerapi&code_challenge=${codeChallenge}&code_challenge_method=S256&redirect_uri=https://auth.tesla.com/void/callback&response_type=code&scope=openid email offline_access&state=123
Note. that's https://auth.tesla.cn and not https://auth.tesla.com, even though I'm not based in China. For some reason if I send the post request to https://auth.tesla.com from my application (and from postman) I just get this HTML:
I've been able to authorize manually via the .cn site so I don't think this is the issue. But if any one knows why I get the above error please say because I have no idea why.
Next I send the post request. In the request I've got the: tesla-auth.sid cookie, hidden form fields, identity parameter, credential parameter and all the parameters mentioned in the api. But this request just returns the same html page that I had before.
Hers's my Code in C#, I call this Authenticate method with the user details, the response for PostPassword should be the 404 but instead it just redirects back to the login.
Any help would be greatly appreciated.
Thanks - Matt
Beta Was this translation helpful? Give feedback.
All reactions