-
Hey, import { createOAuthUserAuth } from '@octokit/auth-oauth-user';
import { graphql } from '@octokit/graphql';
const {
accessToken,
accessTokenExpiresAt,
refreshToken,
refreshTokenExpiresAt,
} = await getTokenFromDatabase();
const userAuth = createOAuthUserAuth({
clientId: secretStore.getGithubClientId(),
clientSecret: secretStore.getGithubClientSecret(),
clientType: 'github-app',
token: accessToken,
// Expects ISO 8601
expiresAt: accessTokenExpiresAt.toISOString(),
refreshToken,
// Expects ISO 8601
refreshTokenExpiresAt: refreshTokenExpiresAt.toISOString(),
});
const apiClient = graphql.defaults({
request: {
hook: userAuth.hook,
},
}); The Since the |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Thanks for reaching out! This feels like a reasonable request to me, and a callback could be a nice way to I planent it whilst keeping the "hook" abstraction. @octokit/js-community What do you think? |
Beta Was this translation helpful? Give feedback.
-
Sounds like a good idea, can you open an issue in https://github.com/octokit/auth-oauth-user.js for the feature request, and include your use case? For the time being, you can workaround by using the
|
Beta Was this translation helpful? Give feedback.
Sounds like a good idea, can you open an issue in https://github.com/octokit/auth-oauth-user.js for the feature request, and include your use case?
For the time being, you can workaround by using the
@octokit/core
SDK instead of the@octokit/graphql
function. It won't add a lot of code, we keep the core SDK intentionally very lightweight. Using the core SDK will give you hooks, which you could use to hook into the request life cycle, and each time a token was refreshed / created, you could save it to your database.@octokit/auth-oauth-user
already has anonVerification
option, we could add a newonTokenCreated
option, which could pass a flag whether it was a refresh or not?