Skip to content

Commit b9af38a

Browse files
committed
OAuth: Update examples
1 parent 4864679 commit b9af38a

File tree

5 files changed

+18
-4
lines changed

5 files changed

+18
-4
lines changed
3.72 KB
Loading

examples/api-examples/src/oauth.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as google from "./oauth/google";
44
import * as twitter from "./oauth/twitter";
55
import * as dropbox from "./oauth/dropbox";
66

7+
// Update the service name here for testing different providers
78
const serviceName = "twitter";
89

910
export default function Command() {
@@ -44,11 +45,11 @@ export default function Command() {
4445
function getService(serviceName: string): Service {
4546
switch (serviceName) {
4647
case "google":
47-
return google as unknown as Service;
48+
return google as Service;
4849
case "twitter":
49-
return twitter as unknown as Service;
50+
return twitter as Service;
5051
case "dropbox":
51-
return dropbox as unknown as Service;
52+
return dropbox as Service;
5253
default:
5354
throw new Error("Unsupported service: " + serviceName);
5455
}
@@ -57,5 +58,4 @@ function getService(serviceName: string): Service {
5758
interface Service {
5859
authorize(): Promise<void>;
5960
fetchItems(): Promise<{ id: string; title: string }[]>;
60-
logout(): void;
6161
}

examples/api-examples/src/oauth/dropbox.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { OAuth } from "@raycast/api";
22
import fetch from "node-fetch";
33

4+
// Create an OAuth app via https://www.dropbox.com/developers/apps
5+
// As redirect URL add: https://raycast.com/redirect?packageName=Extension
6+
// Make sure to select and save the permissions that you add via the scope request parameter
47
const clientId = "YourClientId";
8+
59
const client = new OAuth.PKCEClient({
610
redirectMethod: OAuth.RedirectMethod.Web,
711
providerName: "Dropbox",

examples/api-examples/src/oauth/google.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { OAuth } from "@raycast/api";
22
import fetch from "node-fetch";
33

4+
// Create an OAuth client ID via https://console.developers.google.com/apis/credentials
5+
// As application type choose "iOS" (required for PKCE)
6+
// As Bundle ID enter: com.raycast
47
const clientId = "YourClientId";
8+
59
const client = new OAuth.PKCEClient({
610
redirectMethod: OAuth.RedirectMethod.AppURI,
711
providerName: "Google",

examples/api-examples/src/oauth/twitter.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import { OAuth } from "@raycast/api";
22
import fetch from "node-fetch";
33

4+
// Register a new OAuth app via https://developer.twitter.com/en/portal/dashboard
5+
// Select OAuth 2.0
6+
// As type of app choose: Native App
7+
// For the redirect URL enter: https://raycast.com/redirect
8+
// For the website URL enter: https://raycast.com
49
const clientId = "YourClientId";
10+
511
const client = new OAuth.PKCEClient({
612
redirectMethod: OAuth.RedirectMethod.Web,
713
providerName: "Twitter",

0 commit comments

Comments
 (0)