-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[core-http] Remove ServiceClientCredentials from ServiceClient API #4367
Merged
daviwil
merged 9 commits into
Azure:master
from
daviwil:adieu-service-client-credentials
Jul 25, 2019
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5d7d7e2
Remove ServiceClientCredentials from ServiceClient API
daviwil ad27ff9
Remove additional check added to isTokenCredential
daviwil 39eb836
Improve RawTokenCredential comment
daviwil 7cf5f6e
Improve credential detection logic in ServiceClient
daviwil 1a6f8bf
Add isTokenCredential heuristic to identify TokenClientCredentials
daviwil 4439ce6
Simplify ServiceClient constructor logic around credentials
daviwil f80f304
Move RawTokenCredential from core-http to core-arm
daviwil f8f1304
Delete TokenCredentials, update samples to use RawTokenCredential
daviwil ee97655
Rename RawTokenCredential to SimpleTokenCredential
daviwil File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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,44 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
import { TokenCredential, GetTokenOptions, AccessToken } from "./tokenCredential"; | ||
|
||
/** | ||
* A TokenCredential that always returns the given token. This class can be | ||
* used when the access token is already known or can be retrieved from an | ||
* outside source. | ||
*/ | ||
export class RawTokenCredential implements TokenCredential { | ||
/** | ||
* The raw token string. Can be changed when the token needs to be updated. | ||
*/ | ||
public token: string; | ||
|
||
/** | ||
* The Date at which the token expires. Can be changed to update the expiration time. | ||
*/ | ||
public expiresOn: Date; | ||
|
||
/** | ||
* Creates an instance of TokenCredential. | ||
* @param {string} token | ||
*/ | ||
constructor(token: string, expiresOn?: Date) { | ||
this.token = token; | ||
this.expiresOn = expiresOn ? expiresOn : new Date(Date.now() + 60*60*1000); | ||
} | ||
|
||
/** | ||
* Retrieves the token stored in this RawTokenCredential. | ||
* | ||
* @param _scopes Ignored since token is already known. | ||
* @param _options Ignored since token is already known. | ||
* @returns {AccessToken} The access token details. | ||
*/ | ||
async getToken(_scopes: string | string[], _options?: GetTokenOptions): Promise<AccessToken | null> { | ||
return { | ||
token: this.token, | ||
expiresOnTimestamp: this.expiresOn.getTime() | ||
}; | ||
} | ||
} |
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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are the params having underscore here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are unused in the scope of this function, adding the
_
prefix tells the linter to ignore the fact that they aren't used. I can look into using an eslint rule disable comment instead.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nah, not worth it
this is fine