Show / Hide Table of Contents

    Class TokenHelper

    Methods for working with auth tokens and creating authorized client contexts

    Inheritance
    System.Object
    TokenHelper
    Inherited Members
    System.Object.ToString()
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    Namespace:AzureFunctionsForSharePoint.Common
    Assembly:AzureFunctionsForSharePoint.Common.dll
    Syntax
    public class TokenHelper

    Methods

    | Improve this Doc View Source

    Base64DecodeJwtToken(String)

    Declaration
    public static string Base64DecodeJwtToken(string arg)
    Parameters
    Type Name Description
    System.String arg
    Returns
    Type Description
    System.String
    | Improve this Doc View Source

    Base64UrlEncode(String)

    Declaration
    public static string Base64UrlEncode(string input)
    Parameters
    Type Name Description
    System.String input
    Returns
    Type Description
    System.String
    | Improve this Doc View Source

    GetACSAccessTokens(SharePointContextToken, String, String, String)

    Retrieves an access token from ACS to call the source of the specified context token at the specified targetHost. The targetHost must be registered for principal the that sent the context token.

    Declaration
    public static OAuth2AccessTokenResponse GetACSAccessTokens(SharePointContextToken contextToken, string targetHost, string clientId, string clientSecret)
    Parameters
    Type Name Description
    SharePointContextToken contextToken

    Context token issued by the intended access token audience

    System.String targetHost

    Url authority of the target principal

    System.String clientId

    ACS client id

    System.String clientSecret

    ACS client secret

    Returns
    Type Description
    Microsoft.IdentityModel.S2S.Protocols.OAuth2.OAuth2AccessTokenResponse

    An access token with an audience matching the context token's source

    | Improve this Doc View Source

    GetACSAccessTokens(String, String, String, String, String, String)

    Uses the specified refresh token to retrieve an access token from ACS to call the specified principal at the specified targetHost. The targetHost must be registered for target principal. If specified realm is null, the "Realm" setting in web.config will be used instead.

    Declaration
    public static OAuth2AccessTokenResponse GetACSAccessTokens(string refreshToken, string targetPrincipalName, string targetHost, string targetRealm, string clientId, string clientSecret)
    Parameters
    Type Name Description
    System.String refreshToken

    Refresh token to exchange for access token

    System.String targetPrincipalName

    Name of the target principal to retrieve an access token for

    System.String targetHost

    Url authority of the target principal

    System.String targetRealm

    Realm to use for the access token's nameid and audience

    System.String clientId

    ACS client id

    System.String clientSecret

    Client secret

    Returns
    Type Description
    Microsoft.IdentityModel.S2S.Protocols.OAuth2.OAuth2AccessTokenResponse

    An access token with an audience of the target principal

    | Improve this Doc View Source

    GetAppOnlyAccessToken(String, String, String, String, String)

    Retrieves an app-only access token from ACS to call the specified principal at the specified targetHost. The targetHost must be registered for target principal. If specified realm is null, the "Realm" setting in web.config will be used instead.

    Declaration
    public static OAuth2AccessTokenResponse GetAppOnlyAccessToken(string targetPrincipalName, string targetHost, string targetRealm, string clientId, string clientSecret)
    Parameters
    Type Name Description
    System.String targetPrincipalName

    Name of the target principal to retrieve an access token for

    System.String targetHost

    Url authority of the target principal

    System.String targetRealm

    Realm to use for the access token's nameid and audience

    System.String clientId

    ACS client id

    System.String clientSecret

    ACS client secret

    Returns
    Type Description
    Microsoft.IdentityModel.S2S.Protocols.OAuth2.OAuth2AccessTokenResponse

    An access token with an audience of the target principal

    | Improve this Doc View Source

    GetClientContext(String, String)

    Uses the specified access token to create a client context

    Declaration
    public static ClientContext GetClientContext(string targetUrl, string accessToken)
    Parameters
    Type Name Description
    System.String targetUrl

    Url of the target SharePoint site

    System.String accessToken

    Access token to be used when calling the specified targetUrl

    Returns
    Type Description
    Microsoft.SharePoint.Client.ClientContext

    A ClientContext ready to call targetUrl with the specified access token

    | Improve this Doc View Source

    ReadAndValidateContextToken(String, String, String, String)

    Reads and validates a contextTokenString sent from SharePoint as the result of app launch or a remote event

    Declaration
    public static SharePointContextToken ReadAndValidateContextToken(string contextTokenString, string appHostName, string clientId, string clientSecret)
    Parameters
    Type Name Description
    System.String contextTokenString

    The string sent by SharePoint

    System.String appHostName

    The app host (host part of the site URL)

    System.String clientId

    A valid client id

    System.String clientSecret

    A valid client secret

    Returns
    Type Description
    SharePointContextToken
    • Improve this Doc
    • View Source
    Back to top Copyright © 2016 InstantQuick
    View project on Github