Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async getAccessToken ({
code,
}: {
code: string
}): Promise {
const originalURL = buildURL(concatURL(this.baseURL, 'api/oauth/access_token'), {
client_id: this.clientId,
client_secret: this.clientSecret,
grant_type: 'authorization_code',
code,
})
const proxyURL = typeof this.proxy === 'function'
? this.proxy(originalURL)
: this.proxy
const { data } = await this.$http.post(proxyURL)
return data.access_token
}
redirectAuth (): void {
window.location.href = buildURL(concatURL(this.baseURL, 'oauth_authorize.html'), {
client_id: this.clientId,
redirect_uri: window.location.href,
response_type: 'code',
})
}
async handleAuth (): Promise {
const query = parseQuery(window.location.search)
if (query.code) {
if (query.state !== this.state) {
return null
}
const code = query.code
delete query.code
delete query.state
const replaceURL = buildURL(getCleanURL(window.location.href), query) + window.location.hash
window.history.replaceState(null, '', replaceURL)
const accessToken = await this.getAccessToken({ code })
return accessToken
}
return null
}
GithubV3.prototype.redirectAuthorize = function () {
window.location.href = buildURL('https://github.com/login/oauth/authorize', {
client_id: this.clientId,
redirect_uri: window.location.href,
scope: 'public_repo',
state: this.state,
});
};
GithubV3.prototype.handleAuthorize = function () {
redirectAuth (): void {
window.location.href = buildURL(concatURL(this.baseURL, 'login/oauth/authorize'), {
client_id: this.clientId,
redirect_uri: window.location.href,
response_type: 'code',
state: this.state,
})
}
redirectAuth (): void {
window.location.href = buildURL(concatURL(this.baseURL, 'login/oauth/authorize'), {
client_id: this.clientId,
redirect_uri: window.location.href,
scope: 'public_repo',
state: this.state,
})
}
BitbucketV2.prototype.redirectAuthorize = function () {
window.location.href = buildURL('https://bitbucket.org/site/oauth2/authorize', {
client_id: this.clientId,
redirect_uri: window.location.href,
response_type: 'code',
});
};
BitbucketV2.prototype.handleAuthorize = function () {