Skip to content

OAuth API

OAuthクライアントの設定については下記「NextAuthで使用できるproviderの設定」を参考にしてください

NextAuthで使用できるproviderの設定

jsx
{
  id: "vroid",
  name: "VRoid Hub",
  type: "oauth",
  version: "2.0",
  scope: "default",
  params: { grant_type: "authorization_code" },
  accessTokenUrl: "https://hub.vroid.com/oauth/token",
  requestTokenUrl: "https://hub.vroid.com/oauth/token",
  authorizationUrl: "https://hub.vroid.com/oauth/authorize?response_type=code",
  profileUrl: "https://hub.vroid.com/api/account",
  async profile(profile, tokens) {
    return {
      id: profile.data.user_detail.user.id,
      name: profile.data.user_detail.user.name,
      image: profile.data.user_detail.user.icon.sq170.url
    }
  },
	headers:{
            "X-Api-Version":11 //VRoid Hub独自
          },
  clientId: "",
  clientSecret: ""
}

認証開始のリクエスト

GET: /oauth/authorize

ヘッダー


X-Api-Version

必須: YES

  • VRoid HubのAPIバージョンです。現行バージョンは 11 になります。

クエリパラメータ


response_type

必須: YES
型: string

  • このパラメータには必ず code を入力してください

client_id

必須: YES
型: string

redirect_uri

必須: YES
型: string

scope

必須: YES
型: string


レスポンス

302

  • VRoid Hubの認証ページにリダイレクトします。VRoid Hubでのユーザー認証後、 redirect_uri で設定されたURLに code パラメータと共にリダイレクトされます

400

  • OAuth2.0に準拠したエラーを返します

アクセストークンのリクエスト

POST: /oauth/token

ヘッダー


X-Api-Version

必須: YES

  • VRoid HubのAPIバージョンです。現行バージョンは 11 になります。

リクエストパラメータ


client_id

必須: YES
型: string

client_secret

必須: YES
型: string

redirect_uri

必須: YES
型: string

grant_type

必須: YES
型: string

  • authorization_code を入力してください。リフレッシュトークン利用時は refresh_token を入力してください

code

必須: YES
型: string

  • 「認証開始のリクエスト」時に redirect_uri で受け取った code を入力してください

refresh_token

必須: NO
型: string

  • grant_type = refresh_token の際に、リフレッシュトークンを入力してください

レスポンス

200

{
  "access_token": string,
  "token_type": string,
  "expires_in": number,
  "refresh_token": string
}
  • accsess_token の利用は、APIリクエスト時にヘッダーに Authorization: Bearer ${access_token} を追加してください

400

  • OAuth2.0に準拠したエラーを返します