-
Notifications
You must be signed in to change notification settings - Fork 10
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
Add OAuth utils #20
Add OAuth utils #20
Conversation
f0ba3f8
to
a6403b1
Compare
a6403b1
to
3348090
Compare
}); | ||
``` | ||
|
||
## Example |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's put this above the ### properties
const accessToken = await oauthService.authorize(); | ||
``` | ||
|
||
### Properties |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's rename this to ## Built-in Services
##### Signature | ||
|
||
```ts | ||
const asana: OAuthService |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this any useful? Could we replace it with a description like [OauthService](...) to authenticate with [Asana](...)
with the correct links?
docs/utils-reference/oauth/README.md
Outdated
@@ -0,0 +1,62 @@ | |||
# OAuth | |||
|
|||
Authenticating with OAuth in Raycast extensions is tedious. So we've built a set of utilities to make that task way easier. There's two part to our utilities: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's now blame Raycast, it's the case everywhere 😓
Authenticating with OAuth in Raycast extensions is tedious. So we've built a set of utilities to make that task way easier. There's two part to our utilities: | |
Dealing with OAuth can be tedious. So we've built a set of utilities to make that task way easier. There's two part to our utilities: |
docs/utils-reference/oauth/README.md
Outdated
|
||
Authenticating with OAuth in Raycast extensions is tedious. So we've built a set of utilities to make that task way easier. There's two part to our utilities: | ||
|
||
1. Authenticating with the service using [OAuthService](utils-reference/oauth/OAuthService.md) and some third-party providers (e.g GitHub with `OAuthService.github`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1. Authenticating with the service using [OAuthService](utils-reference/oauth/OAuthService.md) and some third-party providers (e.g GitHub with `OAuthService.github`) | |
1. Authenticating with the service using [OAuthService](utils-reference/oauth/OAuthService.md) or some built-in providers (e.g GitHub with `OAuthService.github`) |
Returns the wrapped component if used in a `view` command or the wrapped function if used in a `no-view` command. | ||
|
||
{% hint style="info" %} | ||
Note that the access token isn't injected into the wrapped component props. Instead, it's been set as a global variable that you can get with `getAccessToken`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's add a link to the getAccessToken
doc here
export default withAccessToken({ authorize })(AuthorizedComponent); | ||
``` | ||
|
||
Note that it also works for `no-view` commands as stated above: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's use tabs like we do in other pages
type OnAuthorizeParams = { | ||
token: string; | ||
type: OAuthType; | ||
idToken: string | null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idToken: string | null; | |
idToken: string | null; // only present if `options.client` has been provided |
src/icon/progress.ts
Outdated
@@ -39,7 +39,7 @@ export function getProgressIcon( | |||
color: Color | string = Color.Red, | |||
options?: { background?: Color | string; backgroundOpacity?: number }, | |||
): Image.Asset { | |||
const background = options?.background || (environment.appearance === "light" ? "black" : "white"); | |||
const background = options?.background || (environment.theme === "light" ? "black" : "white"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why? it's deprecated now
* ``` | ||
* | ||
* @param {object} options - Configuration options for the token acquisition. | ||
* @param {() => Promise<string>} options.authorize - A function to retrieve an OAuth token. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's add this doc to WithAccessTokenParameters
as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright this is looking good 🙌
Add a set of OAuth utils to make it easier to authenticate with services in Raycast extensions. This PR introduces the following utils:
withAccessToken
along withgetAccessToken
to make it easy to fetch and get an authentication token in commands.OAuthService
along with built-in providers (e.g GitHub, Linear, etc.) to make it easy to integrate with OAuth providers.