public void UtilityAuthToStringTest() { AuthLevel a = AuthLevel.Delete; var b = UtilityMethods.AuthLevelToString(a); Assert.AreEqual("delete", b); a = AuthLevel.Read; b = UtilityMethods.AuthLevelToString(a); Assert.AreEqual("read", b); a = AuthLevel.Write; b = UtilityMethods.AuthLevelToString(a); Assert.AreEqual("write", b); a = AuthLevel.None; b = UtilityMethods.AuthLevelToString(a); Assert.AreEqual("none", b); // Invalid auth level a = (AuthLevel)99; b = UtilityMethods.AuthLevelToString(a); Assert.AreEqual(String.Empty, b); }
/// <summary> /// Returns the authorization URL for OAuth authorization, based off the request token and permissions provided. /// </summary> /// <param name="requestToken">The request token to include in the authorization url.</param> /// <param name="perms">The permissions being requested.</param> /// <param name="mobile">Should the url be generated be the mobile one or not.</param> /// <returns></returns> public string OAuthCalculateAuthorizationUrl(string requestToken, AuthLevel perms, bool mobile) { string permsString = (perms == AuthLevel.None) ? "" : "&perms=" + UtilityMethods.AuthLevelToString(perms); return("https://" + (mobile ? "m" : "www") + ".flickr.com/services/oauth/authorize?oauth_token=" + requestToken + permsString); }