All Downloads are FREE. Search and download functionalities are using the official Maven repository.

objc.BasicAuthTokenProvider-body.mustache Maven / Gradle / Ivy

There is a newer version: 7.9.0
Show newest version
#import "{{classPrefix}}BasicAuthTokenProvider.h"

@implementation {{classPrefix}}BasicAuthTokenProvider

+ (NSString *)createBasicAuthTokenWithUsername:(NSString *)username password:(NSString *)password {

    // return empty string if username and password are empty
    if (username.length == 0 && password.length == 0){
        return  @"";
    }

    NSString *basicAuthCredentials = [NSString stringWithFormat:@"%@:%@", username, password];
    NSData *data = [basicAuthCredentials dataUsingEncoding:NSUTF8StringEncoding];
    basicAuthCredentials = [NSString stringWithFormat:@"Basic %@", [data base64EncodedStringWithOptions:0]];

    return basicAuthCredentials;
}

@end




© 2015 - 2024 Weber Informatics LLC | Privacy Policy