🔥 วันนี้แอดขอชี้เป้าเครื่องมือที่ช่วยทดสอบ API นั่นก็คือ Thunder Client ซึ่งจะช่วยให้เราสามารถทดสอบ API ได้ง่ายๆ ผ่าน Visual Studio Code
.
🌈 Thunder Client เป็น GUI-based Rest Api HTTPS client คล้ายกับ Postman เลย ใช้งานง่ายมากๆ โดยมีฟีเจอร์พื้นฐานให้ใช้งานดังนี้
.
✅ ส่ง Http/Https โดยใช้ Methods GET, POST, PUT, DELETE, PATCH, HEAD และ OPTIONS.
✅ มี Tabs History, Collections และ Environment เพื่อให้สะดวกต่อการใช้งาน
✅ รองรับ Basic Auth, Bearer Token และ OAuth 2.0
✅ ส่ง Body ในรูปแบบ Text, Json, Xml, Form Data, Files และ Form-Url-Encoded
✅ มี GUI ที่เข้าใจง่าย ไม่ต้องมีความรู้ในการเขียน Script ก็สามารถใช้งานได้
.
⚡ วิธีการติดตั้งก็ง่ายแสนง่าย เพียงแค่ เปิด VSCode ขึ้นมา คลิกที่ Extention ค้นหาคำว่า “Thunder Client” แล้วคลิก install ได้เลย เมื่อติดตั้งเสร็จแล้วก็จะมีไอคอนของเจ้า Thunder Client อยู่บน side bar
.
⚡ วิธีการใช้งานเพียงแค่คลิกที่ New Request -> ใส่ Web API ที่ต้องการทดสอบ -> เลือก method -> คลิก send รอดูผลลัพธ์ก็เป็นอันเสร็จเรียบร้อย เห็นมั้ยง่ายมากกกกก !!
.
💥 ส่วนใครอยากศึกษาเพิ่มเติมเกี่ยวกับเจ้า Thunder Client สามารถกดลิงค์นี้ได้เลย >> https://github.com/rangav/thunder-client-support
.
borntoDev - 🦖 สร้างการเรียนรู้ที่ดีสำหรับสายไอที่ในทุกวัน
「bearer token」的推薦目錄:
- 關於bearer token 在 BorntoDev Facebook 的最佳貼文
- 關於bearer token 在 Audom Idea Facebook 的最讚貼文
- 關於bearer token 在 HTTP Token 使用方式: Basic Token vs Bearer Token - iT 邦幫忙 的評價
- 關於bearer token 在 What are Bearer Tokens? - YouTube 的評價
- 關於bearer token 在 Verify Bearer Tokens | Gmail - Google Developers 的評價
- 關於bearer token 在 Secure Bearer token in Authorization header in Laravel 的評價
- 關於bearer token 在 Posting with HttpClient and Bearer Token - gists · GitHub 的評價
- 關於bearer token 在 How to interact with the APIs using the new authentication type 的評價
- 關於bearer token 在 A newbie's integration question - bearer token [closed] 的評價
bearer token 在 Audom Idea Facebook 的最讚貼文
ตู้ไปรษณีย์แจ้งเตือนทาง Line สอนทำแบบระเอียดยิ๊บ..
---------------------
จากเมื่อสัปดาห์ที่แล้วผมได้โพสต์วีดีโอทดสอบการทำงานของตู้ไปรษณีย์แจ้งเตือนทางไลน์ไป ก็มีหลายๆคนสนใจผมจึงได้ทำคลิปขึ้นมา เพื่อพาทุกคนทำ ผมวังว่าคลิปนี้จะมีประโยชน์สำหรับใครหลายคนนะครับผม😊
-------------------------------------------------
คลิป https://www.youtube.com/watch?v=_cVsQ1oRuRA&t=108s
--------------------------------------------------
โค้ด
void Line_Notify1(String message1) ;
#include <ESP8266WiFi.h>
#include <DHT.h>
#define WIFI_SSID "ชื่อ wifi" /////////////*************แก้
#define WIFI_PASSWORD "รหัส wifi"////////**************แก้
#define LINE_TOKEN_PIR "line token"////***************แก้
#define PirPin D6
#define DHTPIN D7
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
String message1 = "ข้อความแจ้งเตือน";//****************แก้
bool beep_state = false;
bool send_state = false;
uint32_t ts, ts1, ts2;
void setup() {
Serial.begin(115200);
Serial.println();
pinMode(PirPin, INPUT);
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);
dht.begin();
Serial.println("connecting");
WiFi.mode(WIFI_STA);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.print("connecting");
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.println();
Serial.print("connected: ");
Serial.println(WiFi.localIP());
delay(10000);
Serial.println("Pir Ready!!");
read_sensor();
ts = ts1 = ts2 = millis();
}
void loop() {
ts = millis();
if (WiFi.status() == WL_CONNECTED) {
digitalWrite(LED_BUILTIN, LOW);
} else {
digitalWrite(LED_BUILTIN, HIGH);
}
if ((ts - ts2 >= 60000) && (WiFi.status() == WL_CONNECTED)) {
read_sensor();
}
if ((ts - ts1 >= 5000) && (beep_state == true)) {
beep_state = false;
}
if ((digitalRead(PirPin) == HIGH) && (beep_state == false) && (WiFi.status() == WL_CONNECTED)) {
while (digitalRead(PirPin) == HIGH) delay(100);
Serial.println("Detect !");
Line_Notify1(message1);
beep_state = true;
}
delay(10);
}
void Line_Notify1(String message) {
WiFiClientSecure client;
if (!client.connect("notify-api.line.me", 443)) {
Serial.println("connection failed");
delay(2000);
return;
}
String req = "";
req += "POST /api/notify HTTP/1.1\r\n";
req += "Host: notify-api.line.me\r\n";
req += "Authorization: Bearer " + String(LINE_TOKEN_PIR) + "\r\n";
req += "Cache-Control: no-cache\r\n";
req += "User-Agent: ESP8266\r\n";
req += "Content-Type: application/x-www-form-urlencoded\r\n";
req += "Content-Length: " + String(String("message=" + message1).length()) + "\r\n";
req += "\r\n";
req += "message=" + message1;
// Serial.println(req);
client.print(req);
delay(20);
while (client.connected()) {
String line = client.readStringUntil('\n');
if (line == "\r") {
break;
}
}
}
void read_sensor() {
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
Serial.print("Temperature: ");
Serial.print(t);
Serial.println(" *C ");
}
----------------------------------------------------------
bearer token 在 What are Bearer Tokens? - YouTube 的解答
What are Bearer Tokens ? Watch later. Share. Copy link. Info. Shopping. Tap to unmute. If playback doesn't begin shortly, try restarting your ... ... <看更多>
bearer token 在 Verify Bearer Tokens | Gmail - Google Developers 的解答
Note: Bearer tokens in authorization headers are not sent by default. If you
require a bearer token token to be sent, request it when
registering with Google.
A Bearer Token
is set in the Authorization
header of every In-App Action HTTP Request. For example:
POST /approve?expenseId=abc123 HTTP/1.1
Host: your-domain.com
Authorization: Bearer AbCdEf123456
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/1.0 (KHTML, like Gecko; Gmail Actions)confirmed=Approved
The string "AbCdEf123456" in the example above is the bearer authorization token.
This is a cryptographic token produced by Google.
All bearer tokens sent with actions have the azp
(authorized party) field as
gmail@system.gserviceaccount.com
, with the audience
field specifying the sender domain as a URL of the form
https://
. For example, if the email is from noreply@example.com
, the
audience is https://example.com
.
If using bearer tokens, verify that the request is coming from Google
and is intended for the the sender domain. If the token doesn't verify, the service should
respond to the request with an HTTP response code 401 (Unauthorized)
.
Bearer Tokens are part of the OAuth V2 standard and widely adopted by Google APIs.
Verifying Bearer TokensServices are encouraged to use the open source Google API Client library to verify Bearer tokens:
Java: https://github.com/google/google-api-java-client
Python: https://github.com/google/google-api-python-client
.NET: https://github.com/google/google-api-dotnet-client
Java
import java.io.IOException;
import java.security.GeneralSecurityException;
import java.util.Collections;import com.google.api.client.googleapis.auth.oauth2.GoogleIdToken;
import com.google.api.client.googleapis.auth.oauth2.GoogleIdTokenVerifier;
import com.google.api.client.http.apache.ApacheHttpTransport;
import com.google.api.client.json.jackson2.JacksonFactory;public class TokenVerifier {
// Bearer Tokens from Gmail Actions will always be issued to this authorized party.
private static final String GMAIL_AUTHORIZED_PARTY = "gmail@system.gserviceaccount.com"; // Intended audience of the token, based on the sender's domain
private static final String AUDIENCE = "https://example.com"; public static void main(String[] args) throws GeneralSecurityException, IOException {
// Get this value from the request's Authorization HTTP header.
// For example, for "Authorization: Bearer AbCdEf123456" use "AbCdEf123456"
String bearerToken = "AbCdEf123456"; GoogleIdTokenVerifier verifier = new GoogleIdTokenVerifier.Builder(new ApacheHttpTransport(), new JacksonFactory())
.setAudience(Collections.singletonList(AUDIENCE))
.build(); GoogleIdToken idToken = verifier.verify(bearerToken);
if (idToken == null || !idToken.getPayload().getAuthorizedParty().equals(GMAIL_AUTHORIZED_PARTY)) {
System.out.println("Invalid token");
System.exit(-1);
} // Token originates from Google and is targeted to a specific client.
System.out.println("The token is valid"); System.out.println("Token details:");
System.out.println(idToken.getPayload().toPrettyString());
}
}
Python
import sysfrom oauth2client import client# Bearer Tokens from Gmail Actions will always be issued to this authorized party.
GMAIL_AUTHORIZED_PARTY = 'gmail@system.gserviceaccount.com'# Intended audience of the token, based on the sender's domain
AUDIENCE = 'https://example.com'try:
# Get this value from the request's Authorization HTTP header.
# For example, for "Authorization: Bearer AbCdEf123456" use "AbCdEf123456"
bearer_token = 'AbCdEf123456' # Verify valid token, signed by google.com, intended for a third party.
token = client.verify_id_token(bearer_token, AUDIENCE)
print('Token details: %s' % token) if token['azp'] != GMAIL_AUTHORIZED_PARTY:
sys.exit('Invalid authorized party')
except:
sys.exit('Invalid token')# Token originates from Google and is targeted to a specific client.
print('The token is valid')
... <看更多>
bearer token 在 HTTP Token 使用方式: Basic Token vs Bearer Token - iT 邦幫忙 的解答
在Auth的過程,很常會看到Basic、Bearer 型態的Token,而是用的場景不太一樣。Basic用在存取一個網站、網域的時候,Bearer則是用於存取Protect Resource 的時候。 ... <看更多>