notwo / youknowFrontend

youknowのフロントエンドを担当
0 stars 0 forks source link

Auth0 APIを用いてYouKnowのuser updateに反応させる #93

Closed notwo closed 9 months ago

notwo commented 9 months ago

user_update API

Update a user

token設定

Calling an API

以下を.envとrender.comのEnvironmentに設定する

notwo commented 9 months ago

Auth0のuser updateするためには、headerに"Authorization": 'Bearer ...'の形式でAPIアクセストークンを埋め込む必要がある getAccessTokenSilently()だとBearerのtokenが間違っていて400エラーになる Auth0 Bad HTTP authentication header format using curlに従い、Management APIの設定をする

notwo commented 9 months ago

おそらくSPAでは "grant_type":"client_credentials" は無理

notwo commented 9 months ago

Update a userではリクエストパラメータにbodyを入れているが、実際には入れては駄目。 エラーメッセージを無視して直接nicknameとemailを送ってみたところうまく行った 返却値で現在userの設定値が返される 更新直後にAuth0側のログインが外れるため、リロードすると再ログインが必須になる(更新直後に他のデータを見たり更新したりすることは可能)

notwo commented 9 months ago

本番環境(render.com)にVITE_AUTH0_API_ACCESS_TOKENの設定が必要