-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for getting OAuth token info (#205)
# Description This PR adds support for the /v3/connect/tokeninfo endpoint. # Usage There are two methods that are part of the `Auth` resource that allow you to get information on a token; one for the ID token (`idTokenInfo`) and one for the access token (`accessTokenInfo`). ```java NylasClient nylas = new NylasClient.Builder("API_KEY").build(); // Get information on an ID token Response<TokenInfoResponse> idTokenInfo = nylas.auth.idTokenInfo("idToken"); // Get information on an access token Response<TokenInfoResponse> accessTokenInfo = nylas.auth.accessTokenInfo("accessToken"); ``` # License <!-- Your PR comment must contain the following line for us to merge the PR. --> I confirm that this contribution is made under the terms of the MIT license and that I have the authority necessary to make this contribution on behalf of its copyright owner.
- Loading branch information
1 parent
42cd063
commit 65b8977
Showing
6 changed files
with
135 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.nylas.models | ||
|
||
import com.squareup.moshi.Json | ||
|
||
/** | ||
* A request to query the information of a token. | ||
* @suppress Used internally by the SDK | ||
*/ | ||
data class TokenInfoRequest( | ||
/** | ||
* The ID token to query. | ||
*/ | ||
@Json(name = "id_token") | ||
val idToken: String? = null, | ||
/** | ||
* The access token to query. | ||
*/ | ||
@Json(name = "access_token") | ||
val accessToken: String? = null, | ||
) : IQueryParams |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.nylas.models | ||
|
||
import com.squareup.moshi.Json | ||
|
||
data class TokenInfoResponse( | ||
/** | ||
* The issuer of the token. | ||
*/ | ||
@Json(name = "iss") | ||
val iss: String, | ||
/** | ||
* The token's audience. | ||
*/ | ||
@Json(name = "aud") | ||
val aud: String, | ||
/** | ||
* The time that the token was issued. | ||
*/ | ||
@Json(name = "iat") | ||
val iat: Int, | ||
/** | ||
* The time that the token expires. | ||
*/ | ||
@Json(name = "exp") | ||
val exp: Int, | ||
/** | ||
* The token's subject. | ||
*/ | ||
@Json(name = "sub") | ||
val sub: String? = null, | ||
/** | ||
* The email address of the Grant belonging to the user's token. | ||
*/ | ||
@Json(name = "email") | ||
val email: String? = null, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters