Yahoo
Implements OpenID Connect.
For usage, see OAuth 2.0 provider.
import { Yahoo } from "arctic";
const yahoo = new Yahoo(clientId, clientSecret, redirectURI);
const url: URL = await yahoo.createAuthorizationURL(state, {
// optional
scopes
});
const tokens: YahooTokens = await yahoo.validateAuthorizationCode(code);
const tokens: YahooTokens = await yahoo.refreshAccessToken(refreshToken);
Get user profile
Add the profile
scope. Optionally add the email
scope to get user email.
const url = await yahoo.createAuthorizationURL(state, {
scopes: ["profile", "email"]
});
Parse the ID token or use the userinfo
endpoint. See ID token claims.
const tokens = await yahoo.validateAuthorizationCode(code);
const response = await fetch("https://api.login.yahoo.com/openid/v1/userinfo", {
headers: {
Authorization: `Bearer ${tokens.accessToken}`
}
});
const user = await response.json();