gitpod-samples / Gitpod-Raycast-Extension

Raycast Extension for Gitpod
MIT License
15 stars 6 forks source link

Use the Gitpod endpoint from the preferences everywhere #72

Closed mads-hartmann closed 10 months ago

mads-hartmann commented 11 months ago

This PR fixes a regression in the extension where the Gitpod URL that a user might supply in the extension preferences wasn't used everywhere in the code-base.

Specifically, if you used a custom Gitpod URL and supplied a Personal Access Token, then you'd get an error about the PAT being invalid when trying to use the Manage Workspaces command. This is because it would try to validate the PAT against gitpod.io rather than the custom Gitpod endpoint the user provided ☺️

This PR should fix all hardcoded references to gitpod.io.

Unfortunately I haven't been able to test this change. When I'm running npm run dev and try to use the extension it wants me to authenticate with GitHub, and when I do I get an error. Any idea how to fix this?

Screenshot 2023-11-06 at 15 19 33 page:

Palanikannan1437 commented 11 months ago

Hey @mads-hartmann, thank you so much for this awesome PR and taking out the time

I just pushed these changes to develop,

To solve the issue you're facing, could you please modify the oauth urls at these two parts and try again?

In the src/api/oauth.ts

  const authRequest = await oauthClient.authorizationRequest({
    endpoint: "https://github.oauth.raycast.com/authorize",
    clientId,
    scope: "repo read:org user",

and

  const response = await fetch("https://github.oauth.raycast.com/token", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
      client_id: clientId,
      code: authCode,
      code_verifier: authRequest.codeVerifier,
      grant_type: "authorization_code",
      redirect_uri: authRequest.redirectURI,
    }),

Basically replace https://github.oauth-proxy.raycast.com/token with https://github.oauth.raycast.com/token

mads-hartmann commented 11 months ago

@Palanikannan1437 That works like a charm and I was able to validate that I can now use the extension with our internal Gitpod Dedicated installation 🥳

Palanikannan1437 commented 10 months ago

LFG!!!! That sounds awesome, thanks so much for this contribution 🙏, though I don't have access to Gitpod dedicated yet for testing purposes, I'll try going through the code and merge this one in as soon as possible!!

Also how are you liking the extension? Do you think there's something missing we could add in?

mads-hartmann commented 10 months ago

Also how are you liking the extension? Do you think there's something missing we could add in?

Getting this fixed has been a blocker for incorporating it into my daily dev flows. Once I use it a bit more I'll for sure reach out in Discord if I have any feedback 🧡

mads-hartmann commented 10 months ago

@Palanikannan1437 Anything I can do to help land this? 🧡

Palanikannan1437 commented 10 months ago

@Palanikannan1437 Anything I can do to help land this? 🧡

Yeah indeed, is there anyway I could test this? With maybe a custom endpoint you have for testing?

mads-hartmann commented 10 months ago

Yeah indeed, is there anyway I could test this? With maybe a custom endpoint you have for testing?

Ah, sorry, must have miscommunicated. I tested this here and have been running with my locally built version of the extension the last couple of week. Everything seems fine so far ☺️

mads-hartmann commented 10 months ago

@Palanikannan1437 I don't have a Gitpod installation you can test against I'm afraid. All the Gitpod Dedicated instances are tied up to SSO so there's no easy way to give you access ☺️

Palanikannan1437 commented 10 months ago

Ohhh no issues, I can totally understand!!

The code looks good to me, thanks so much for this PR!!

mads-hartmann commented 10 months ago

@Palanikannan1437 Awesome, thanks! Let me know once it's in the Raycast store so I can let the team know about it internally and push for some more adoption of the Raycast extension ☺️