Skip to content

Commit 2081b58

Browse files
[feat] GitHub OAuth added for simpler auth (#27)
* GitHub OAuth added for simpler auth
1 parent 647b553 commit 2081b58

File tree

5 files changed

+5
-18
lines changed

5 files changed

+5
-18
lines changed

assets/Icons/gh-icon.png

6.24 KB
Loading

assets/Icons/[email protected]

4.72 KB
Loading

package.json

+1-12
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,6 @@
4141
]
4242
}
4343
],
44-
45-
"preferences": [
46-
{
47-
"name": "personalAccessToken",
48-
"title": "Personal Access Token",
49-
"placeholder": "Visit https://github.com/settings/tokens",
50-
"description": "Enter Classic Personal Access Token from GitHub",
51-
"type": "password",
52-
"required": true
53-
}
54-
],
5544
"dependencies": {
5645
"@graphql-codegen/cli": "^2.16.2",
5746
"@graphql-codegen/typescript-graphql-request": "^4.5.8",
@@ -84,4 +73,4 @@
8473
"publish": "ray publish",
8574
"generate": "graphql-codegen --config codegen.ts"
8675
}
87-
}
76+
}

src/api/oauth.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const clientId = "7235fe8d42157f1f38c0";
66
export const oauthClient = new OAuth.PKCEClient({
77
redirectMethod: OAuth.RedirectMethod.Web,
88
providerName: "GitHub",
9-
providerIcon: environment.theme === "light" ? "icon.png" : "[email protected]",
9+
providerIcon: environment.theme === "light" ? "Icons/gh-icon.png" : "Icons/gh-[email protected]",
1010
providerId: "github",
1111
description: "Connect your GitHub account",
1212
});
@@ -21,7 +21,7 @@ export async function authorize() {
2121
const authRequest = await oauthClient.authorizationRequest({
2222
endpoint: "https://github.oauth-proxy.raycast.com/authorize",
2323
clientId,
24-
scope: "notifications repo read:org read:user read:project",
24+
scope: "repo read:org user",
2525
});
2626

2727
const { authorizationCode } = await oauthClient.authorize(authRequest);

src/helpers/withGithubClient.tsx

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Detail, environment, MenuBarExtra } from "@raycast/api";
2-
import { getPreferenceValues } from "@raycast/api";
32
import { GraphQLClient } from "graphql-request";
43
import { Octokit } from "octokit";
54
import { useMemo, useState } from "react";
@@ -16,9 +15,8 @@ export function withGithubClient(component: JSX.Element) {
1615
// we use a `useMemo` instead of `useEffect` to avoid a render
1716
useMemo(() => {
1817
(async function () {
19-
const { personalAccessToken } = getPreferenceValues();
20-
const token = personalAccessToken || (await authorize());
21-
const authorization = personalAccessToken ? `token ${token}` : `bearer ${token}`;
18+
const token = await authorize();
19+
const authorization = `bearer ${token}`;
2220
github = getSdk(new GraphQLClient("https://api.github.com/graphql", { headers: { authorization } }));
2321

2422
octokit = new Octokit({ auth: token });

0 commit comments

Comments
 (0)