|
|
|
|
|
- Properties specific to JWTParameters variables:
- Getting parameters from a Google JSON file
JWTParameters (Variable type) In french: JWTParamètres
The JWTParameter type is used to define all the data required for JWT-based authentication. You can define and change the characteristics of this type using different WLanguage properties. A JSON Web Token (JWT) consists of 3 strings separated by dots ("."): - The first part, the header, is a Base64Url-encoded JSON that describes the token type and the algorithm used for signing.
- The second part, the payload, is a Base64Url-encoded JSON containing the claims. This JSON can contain predefined claims that provide additional information about the token (expiration time, audience, subject, etc.).
- The last part, the signature, ensures the token's authenticity. This signature is generated from the first 2 segments using a specific algorithm (e.g., HS256 with a secret key).
Note: For more details on the declaration of this type of variable and the use of WLanguage properties, see Declaring a variable. New in version 2025JWTParams is JWTParameters
JWTParams.TokenURL = "https://oauth2.googleapis.com/token"
JWTParams.Scope = "https://www.googleapis.com/auth/firebase.messaging"
JWTParams.Issuer = "firebase-adminsdk-m4j35@notifpushandroid28.iam.gserviceaccount.com"
JWTParams.Encryption = jwtRS256
JWTParams.PrivateKeyID = "8ae8fe7c76c9f6dbebaf5cba066e14ac26165277"
JWTParams.AdditionalParameters = [
sub=Test
nom=TOTO
email=toto@gmail.com
]
JWTParams.PrivateKey = [
-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDLqXc2nE0iTK++
puV2N+H2DoXLjwi36y84LRdLFbfT7BIybOBehIhfGRNY3NsdCShw2VhGGHn1sWl5
2+w6Y2VCZqbMG0XfowdVq1TExyuIeEcRhieiG4EMjP6+yIvwf7rIkmjmflisHBks
iXNeBx1CwvfpafU3ssMAaQ+F1z8LhN1w5REAx8+nALMFOoGHK83edutxesqggpyk
bmcKM8R18ty9au6/sTcOXmnCy</span>KnSk8kOGvvjSvQG3UVWIKUrXdRxGami+Z7EhW
YBJRMlK1YFOzTLJo1kRebUBvZxMXCWxwYjj3uLIk9a/EtTUEVvSvSxxy7KTGK5Xi
9h8hf9UdAgMBAAECggEAD/6oMS7HVAlHyCZdY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G
33xcBTwrmVKutEZH96BU77/IdD6B7s4jP0v7n9omdhttcVtBl5KThmNpvMAhbtb7
7coQ/ynoCpRZROS58hHhYQjIIuQO2RAsxBnaXP1gUFjQr9huDtgT9CDr8PoIIwYV
yYMBbJxhKhlBY9gYByl5G1qO
-----END PRIVATE KEY-----
]
MyToken is AuthToken = AuthIdentify(JWTParams)
IF MyToken.Valid THEN
Info("ok")
ELSE
Info(ErrorInfo(errFullDetails))
END
Properties Properties specific to JWTParameters variables: The following properties can be used to handle a JWT-based authentication mechanism: | | | Property name | Type used | Effect |
---|
AdditionalParameters | Character string | Additional token parameters (used in the payload). | New in SaaSAdditionalURL parameters | Character string | Parameters of the first authentication request. This string must be formatted as URL parameters. | Certificate | Certificate | Certificate to be used for the token signature. This certificate is only used for jwtRS256 encryption. | Consumer | Character string | Token consumers (audience). | Encryption | Integer constant | Encryption algorithm used: - jwtHS256: HS256 algorithm (corresponds to HMAC encryption combined with SHA 256 encryption).
- jwtRS256: RS256 algorithm (corresponds to RSA encryption combined with SHA 256 encryption).
| Issuer | Character string | Authentication issuer. | PrivateKey | Character string | Text representing the private key. This text starts with "-----BEGIN PRIVATE KEY-----" or "-----BEGIN RSA PRIVATE KEY-----". This property is not required if the Certificate property has been set. | PrivateKeyID | Character string | Secret application access code. This code is provided by the service when registering the application. | Scope | Character string | Requested permissions. The possible values are specific to the web service used. | Subject | Character string | Main subject of the token. | TokenURL | Character string | URL for retrieving the access token to use (second URL of OAuth 2.0 standard). |
Remarks Getting parameters from a Google JSON file MyToken is AuthToken
JWTParams is JWTParameters
JWTParams = JSONToJWTParameters("C:\.<Google JSON file.>.\wd-mail-324009-72613ff8bc14.json")
JWTParams.Scope = "https://mail.google.com"
MyToken = AuthIdentify(JWTParams)
IF NOT MyToken.Valid THEN
Error(ErrorInfo(), HTMLToText(MyToken.ServerResponse))
RETURN
END
ToastDisplay("Connection successful", toastShort, vaBottom, haCenter)
INTERNAL PROCEDURE JsonVersJWTParamètres(sJSFileName, nCleCryption is an integer = jwtRS256): JWTParamètres
jwtFromJsOAuth is JWTParameters
jsOAuth is JSON = fLoadBuffer(sJSFileName)
jwtFromJsOAuth.TokenURL = jsOAuth.token_uri..Value
jwtFromJsOAuth.Issuer = jsOAuth.client_email..Value
jwtFromJsOAuth.PrivateKeyID = jsOAuth.private_key_id..Value
jwtFromJsOAuth.PrivateKey = jsOAuth.private_key..Value
jwtFromJsOAuth.Scope = jsOAuth.universe_domain..Value
jwtFromJsOAuth.Encryption = nEncryptionKey
RETURN jwtFromJsOAuth
END
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|