GetToken
The GetToken tool gets access tokens.
Set the environment
Before executing the command, set the environment using the envidp script, found in $FGLDIR/web_utilities/services/gip. On Microsoft® Windows, the script is named envidp.bat.
Syntax
GetToken command [
options ]
scopes
- There are two commands to get tokens from an Identity Provider such as the Genero Identity
Provider (GIP):
- client_credentials gets an access token using the service application client id and secret id.
- password gets an access token using the GIP user's username and password.
- options. Options are specific to commands and these are described in the tables.
- scopes specify permissions for access to
resources of web services or applications secured on the GIP. Scopes limit the bearer of the token
to accessing specific resources. You must specify at least one scope. If more than one scope is
needed, you can specify them in a list separated by spaces. For example,
myAppScope myWSScope
might define scopes for a secure application and web service the user requires access to.
Syntax 1: client credentials
GetToken client_credentials [
options ]
scopes
- options are described in the client_credentials options.
- scopes specify permissions for access to
resources of web services or applications secured on the GIP. Scopes limit the bearer of the token
to accessing specific resources. You must specify at least one scope. If more than one scope is
needed, you can specify them in a list separated by spaces. For example,
myAppScope myWSScope
might define scopes for a secure application and web service the user requires access to.
Syntax 2: password
GetToken password [
options ]
scopes
- options are described in the Password options.
- scopes specify permissions for access to
resources of web services or applications secured on the GIP. Scopes limit the bearer of the token
to accessing specific resources. You must specify at least one scope. If more than one scope is
needed, you can specify them in a list separated by spaces. For example,
myAppScope myWSScope
might define scopes for a secure application and web service the user requires access to.
Option | Description |
---|---|
-h
or
|
Displays help for the client_credentials command. |
|
Specifies the service application client id. |
|
Specifies the service application secret id. |
-f, --savetofile
filename
|
Save access token to file. |
-i, --idp URL
|
URL of IdP |
Option | Description |
---|---|
-h
or
|
Displays help for the password command. |
|
Specifies the name of the IdP user. |
|
Specifies the password of the IdP user |
-f, --savetofile
filename
|
Save access token to file. |
-i, --idp URL
|
URL of IdP |
Usage
The GetToken tool is located in the $FGLDIR/web_utilities/services/gip/bin/gettoken directory.
Run the GetToken command to get access tokens at the command line. You can use this command to work with applications or services secured by the GIP via a script. The access token got via this command is valid for 10 minutes only. An access token got from the GIP when starting an application is valid for one hour and continues to be refreshed automatically till the application is closed.
Get an access token for a web service secured by the GIP
GetToken password -u user -p mypw
--idp https://host:port/gas/ws/r/services/GeneroIdentityProvider
--savetofile mytoken.json myWSScope
In this example:- The password command is used. Tip:
If you need an access token on behalf of a user, you use the
password
option. If you need an access token for a service-to-service application, such as a script which does not have to be run on behalf of a user, use theclient_credentials
option. - The IdP user's name and password is provided in
-u user -p mypw
. - The URL of the Genero Identity Provider is specified.
- mytoken.json is the filename where the access token is saved.
myWSScope
is the scope of the service required in the token.
Access token generated is valid for a limited time
The access token got via this command is valid for 10 minutes only. An access token got from the GIP when starting an application is valid for one hour and continues to be refreshed automatically till the application is closed.
Display help for the GetToken command
GetToken password --help
GetToken client_credentials --help