Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix OAuth token retrieval #419

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/myq-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,10 @@ export class myQApi {

body: loginBody.toString(),
headers: {

"Authorization": "Basic SU9TX0NHSV9NWVE6",
"Content-Type": "application/x-www-form-urlencoded",
"Cookie": cookie
"Cookie": cookie,
"Accept": "*/*"
},
method: "POST",
redirect: "manual"
Expand Down Expand Up @@ -289,13 +290,13 @@ export class myQApi {
// Create the request to get our access and refresh tokens.
const requestBody = new URLSearchParams({

"client_id": MYQ_API_CLIENT_ID,
"client_secret": Buffer.from(MYQ_API_CLIENT_SECRET, "base64").toString(),
// "client_id": MYQ_API_CLIENT_ID,
// "client_secret": Buffer.from(MYQ_API_CLIENT_SECRET, "base64").toString(),
"code": redirectUrl.searchParams.get("code") as string,
"code_verifier": pkce.code_verifier,
"grant_type": "authorization_code",
"redirect_uri": MYQ_API_REDIRECT_URI,
"scope": redirectUrl.searchParams.get("scope") as string
"redirect_uri": MYQ_API_REDIRECT_URI
// "scope": redirectUrl.searchParams.get("scope") as string
});

// Now we execute the final login redirect that will validate the PKCE challenge and return our access and refresh tokens.
Expand Down