0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

LINE Messaging APIの登録〜アクセストークンを発行

Posted at

はじめに

LINE MEssaging APIの登録からアクセストークンの発行までをまとめました

LINE MEssaging APIの登録

LINE Developpersのサイトにアクセスして会員登録をします

会員登録の方法は省略します

Messaging APIの「詳細はこちら」をクリックします
スクリーンショット 2023-03-01 19.57.24.png

「今すぐはじめよう」をクリックします
スクリーンショット 2023-03-01 19.58.54.png

「Create a new channel」の画面が開くので項目を適宜埋めていきます

これでMessagingAPIの登録は完了です。

次にアクセストークンを発行します

アクセストークンの発行

今回は30日有効なアクセストークンを発行することにします

下記のサイトが参考になりました
https://developers.line.biz/ja/reference/messaging-api/#revoke-channel-access-token-v2-1

curl -v -X POST https://api.line.me/v2/oauth/accessToken \
-H "Content-Type: application/x-www-form-urlencoded" \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'client_id={channel ID}' \
--data-urlencode 'client_secret={channel secret}'

上記のコマンドの4行目{channel ID}、5行目の{channel secret}に
先ほど登録が完了したMessaging APIのコンソール画面のBasic settingタブに記載がある値をセットしてcurlをターミナル等で実行します

$ curl -v -X POST https://api.line.me/v2/oauth/accessToken \
> -H "Content-Type: application/x-www-form-urlencoded" \
> --data-urlencode 'grant_type=client_credentials' \
> --data-urlencode 'client_id=12345' \
> --data-urlencode 'client_secret=q3904tguvj03932d'
...
* successfully set certificate verify locations:
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN, server accepted to use h2
{"access_token":"fjqi3o48gf2a3","expires_in":12345,"token_type":"Bearer"}

コマンドを実行すると、出力結果の最後に"access_token"が出力されます
これのvalue値がアクセストークンです

以上です

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?